linux btop 101

背景 最近发现一个很好用的系统监控命令:btop。 btop一站式实时显示cpu,memory,disk,network,processes的统计信息。 ...

September 25, 2021

利用WSL和wget从github下载文件

背景 由于GFW的干扰,即使科学上网方式从github下载文件,下载连接经常会被中断。由于chrome重新连接的次数有限,据说chrome重新建立连接重试次数最大为5次。所以遇到一个大的下载文件,通常是不会下载成功,费时费力费心。 ...

July 31, 2020

git FAQ

从Git历史中彻底删除大文件 描述 1 2 3 4 5 remote: Resolving deltas: 100% (23/23), completed with 17 local objects. remote: error: Trace: 4836afb0ea0a96bb85e61a8ae818673e2f110a05c0da9e6813f8fa0c34ba2816 remote: error: See https://gh.io/lfs for more information. remote: error: File pdsv3.json is 184.08 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage 方案 备份当前代码(防止操作失误) ...

May 11, 2017

Linux进程诊断小结

日常工作中最常见问题是如何诊断一个进程运行过程中出现的问题,下面的总结从进程诊断的角度来展示,而是不从工具与命令角度来展示,进程诊断是工作的主体,工具与命令只是工具。 ...

May 10, 2017

git常用命令总结

配置 config user 1 2 git config --global user.email "you@example.com" git config --global user.name "Your Name" Ignore Git permission changes 1 git config core.fileMode false Fix .gitignore 1 git rm -r --cached . git仓库 初始化一个版本仓库 1 git init clone远程版本库 1 git clone git@github.com:myself659/FFmpeg.git 添加远程版本库origin 1 git remote add origin git@github.com:myself659/rtmpserver_demo.git 查看远程仓库信息 1 git remote -v 删除远程仓库 1 git remote rm <repository> git修改 添加当前修改的文件到暂存区 1 git add . 提交修改到本地 1 git commit -m "fix bug 0001" 提交修改到远程 1 git push -u origin master 查看修改状态 1 git status 重命名文件 1 git mv README readme 从版本库中删除文件 1 git rm readme 取消对文件修改 1 git checkout -- readme 修改最新一次修改注释 1 git commit amend 显示所有提交 1 git show 1 git show <commit> --stat 1 git show <commit> -- <filepath> 恢复最后一次提交的状态 1 git revert HEAD 恢复某次提交的状态 1 git revert <$id> Remove untracked files & directories 1 2 3 4 # To remove untracked files git clean -f # TO remove untracked directories git clean -fd Discard local changes 1 git reset --hard Delete untracked files 1 git clean -fd git commit Edit last commit in both local and remote repository 1 2 3 4 5 6 7 8 9 # Step 1: Check recent commit history git show HEAD # Step 2: Update commit locally git add <file-path(s)> git commit --amend -m "<New-commit-message>" # Step 3: Check recent commit history to verify the correct edit git show HEAD # Step 4: Push the edit upstream git push -f # Then, verify it in the web interface of the hosting service Delete last commit in both local and remote repository 1 2 3 4 5 6 7 # Step 1: Check recent commit history to check git log --oneline -5 # Step 2: Delete commit locally and push the change to remote git reset --soft HEAD~1 # Delete commit locally git push -f # Delete commit upstream # Step 3: Check recent commit history to check git log --oneline -5 git repository rename repository 1 2 3 4 5 6 7 8 9 10 # Step 1: Rename local repository cd .. # Go to the directory that holds the repository mv <repo-old-name> <repo-new-name> cd <repo-new-name> # Step 2: Check remote url git remote -v # Step 3: Update remote url git remote set-url origin <new-url> # Step 4: Check remote url for verification git remote -v git log 查看修改log 1 git log 查看指定文件每次提交记录 1 git log <filename> 查看最近两次详细修改内容的diff 1 git log -p -2 查看提交统计信息 1 git log --stat Move a commit from one branch to another 1 git cherry-pick COMMIT-HASH 查看项目各个成员提交代码统计 1 git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done git log graph 1 git log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%an%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %s%C(reset)' --all git分支 查看远程分支 1 git branch -r 创建新分支 1 git branch <new_branch> 1 git checkout -b NEW-BRANCH-NAME 查看各分支创建最后提交信息 1 git branch -v 删除指定分支 1 2 git branch -d <branch_name> git push origin -d <branch-name> 强制删除指定分支 1 git branch -D <branch_name> 查看已经被合并到当前分支的分支 1 git branch --merged 查看尚未被合并到当前分支的分支 1 git branch --no-merged 合并分支 1 git merge <merge_branch> 切换分支 1 git checkout <branch_name> -f 抓取远程仓库所有分支更新并合并到本地 1 git pull 抓取远程仓库所有分支更新并合并到本地,不要快进合并 1 git pull --no-ff 抓取远程仓库更新 1 git fetch origin push所有分支 1 git push 将本地主分支推到远程主分支 1 git push origin master 将本地主分支推到远程(如无远程主分支则创建,用于初始化远程仓库) 1 git push -u origin master 创建远程分支 1 git push origin <local_branch>:<remote_branch> 查看所有分支名称 1 git branch --all check branch status 1 git status rename local branch 1 git branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME rename remote branch 1 git push origin :OLD-BRANCH-NAME NEW-BRANCH-NAME Delete a branch on a remote repository 1 git push REMOTE-NAME --delete BRANCH-NAME clean git branches exclude main and master 1 git branch | grep -v "master" | grep -v "main" | grep -v ^\* | xargs git branch -D; Create a local copy of the existing remote branch 1 2 git fetch origin git switch --track origin/<branch-name> git diff 比较当前文件和暂存区文件差异 1 git diff <file> 比较两次提交之间的差异 1 git diff <$id1> <$id2> 比较两个分支 1 git diff <branch1> <branch2> 比较统计信息 1 git diff --stat 提交git diff How to Include Diff into Git Commit Message ...

May 21, 2016

Linux内核常见crash原因

前言 与前同事交流,发现以前的技术经历与解决的问题,现在接触不多,但是想想还是很有意思,虽然很多细节现在已经不能表达出来或展示出来,但是还得写出来。下面写的得主要个人经历的linux内核crash原因。 ...

April 17, 2016

Linux x86-64 函数调用栈实例分析

前言 动手实践并写文章花5倍的时间一次性把事情做到90分,好过读别人文章只能做到60分,后面还需要花时间继续深入学习(做事情一定要做到有效的阈值)。本文目的希望通过分析一个简单的函数调用加深对x86-64寄存器及栈帧的结构的认识,以便在定位问题需要的时候能够熟练运用。 ...

March 9, 2016

docker image命令实践

搭建了docker环境,就来体验一下Docker,常用docker image命令如下: 1. 搜索docker image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 root@localhost ~]# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 2954 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 58 [OK] dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC on po... 32 [OK] torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 25 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components... 22 [OK] tleyden5iwx/ubuntu-cuda Ubuntu 14.04 with CUDA drivers pre-installed 18 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 16 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC sessi... 8 [OK] ioft/armhf-ubuntu [ABR] Ubuntu Docker images for the ARMv7(a... 7 [OK] n3ziniuka5/ubuntu-oracle-jdk Ubuntu with Oracle JDK. Check tags for ver... 7 [OK] nuagebec/ubuntu Simple always updated Ubuntu docker images... 4 [OK] nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli installed 3 [OK] nimmis/ubuntu This is a docker images different LTS vers... 3 [OK] maxexcloo/ubuntu Docker base image built on Ubuntu with Sup... 2 [OK] sylvainlasnier/ubuntu Ubuntu 15.10 root docker images with commo... 1 [OK] isuper/base-ubuntu This is just a small and clean base Ubuntu... 1 [OK] densuke/ubuntu-jp-remix Ubuntu Linuxの日本語remix風味です 1 [OK] seetheprogress/ubuntu Ubuntu image provided by seetheprogress us... 1 [OK] nickistre/ubuntu-lamp LAMP server on Ubuntu 1 [OK] teamrock/ubuntu TeamRock's Ubuntu image configured with AW... 0 [OK] konstruktoid/ubuntu Ubuntu base image 0 [OK] birkof/ubuntu Ubuntu 14.04 LTS (Trusty Tahr) 0 [OK] zoni/ubuntu 0 [OK] esycat/ubuntu Ubuntu LTS 0 [OK] rallias/ubuntu Ubuntu with the needful 0 2. 下载image 1 docker pull 3. 查看image 1 2 3 4 5 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest d55e68e6cc9c 4 weeks ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB training/sinatra latest f0f4ab557f95 19 months ago 447 MB 4. 删除image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [root@localhost ~]# docker rm training/sinatra Error response from daemon: no such id: training/sinatra Error: failed to remove containers: [training/sinatra] [root@localhost ~]# docker rm f0f4ab557f95 Error response from daemon: no such id: f0f4ab557f95 Error: failed to remove containers: [f0f4ab557f95] [root@localhost ~]# docker rmi f0f4ab557f95 Untagged: training/sinatra:latest Deleted: f0f4ab557f954f3e04177663a3af90e88641bcdcce1f02ac900dbd9768ef4945 Deleted: 79e6bf39f99322cc062a79bec4a09de0dd19cb7f5f735b4b6b7832c04b13bb45 Deleted: ce80548340bb03726d391bb8fa4d134f8418c2fff90be9a7323560debdea9bd2 Deleted: e809f156dc985e07105fdc86ec05eb03eb7aac8636dc210e8595d31b55787f4a Deleted: bfab314f3b766eddf9778f8dce089f44e84ea028f4a44ce68740dce81a844ec8 Deleted: be88c4c27e80023b6aea82f0f2e15fb21c6f4193fe814e5b58010d356dd7846b Deleted: 3e76c0a80540a0d36493ae7110796fc92f559a191454e3ac19c1d4c650bdd9e0 Deleted: 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 You have new mail in /var/spool/mail/root [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest af88597ec24b 6 days ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB 5. 运行image 1 [root@localhost ~]# docker run -i -t apache2 6. kill运行的docker image 1 2 3 4 5 6 7 8 9 10 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 68333b272b52 ubuntu "/bin/bash" 18 minutes ago Up 18 minutes clever_babbage 0ca2aff5b94b ubuntu "bash" 48 minutes ago Up 48 minutes focused_hypatia You have new mail in /var/spool/mail/root [root@localhost ~]# docker kill 68333b272b52 68333b272b52 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0ca2aff5b94b ubuntu "bash" 54 minutes ago Up 54 minutes focused_hypatia 7. 制作image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@localhost tmp]# more Dockerfile FROM apache2 RUN apt-get install -y wget [root@localhost tmp]# docker build -t wget . Sending build context to Docker daemon 2.609 MB Sending build context to Docker daemon Step 0 : FROM apache2 ---> f5cf247f22af Step 1 : RUN apt-get install -y wget ---> Running in ab3cd326c53c [root@localhost tmp]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE wget latest be8bf51f39d5 29 seconds ago 229.1 MB apache2 latest f5cf247f22af 5 hours ago 223.8 MB ubuntu latest af88597ec24b 6 days ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB 8. docker volume clean 1 docker system prune --all --volumes --force

January 28, 2016

升级Linux内核,搭建docker环境

docker可以说是去年最热的技术,也是业界大谈特谈的技术,到了今年有很多公司已经将docker应用于自己的生产环境。Docker已经从一个工具转化成平台,小生态圈。作为一名程序员应该与时俱进,学习新技术,不断地提高自己。 ...

December 13, 2015

gdb自定义断点操作

gdb是c/c++上调试利器,有很多技巧能让调试程序与解决问题更加方便与高效,下面关于command 命令的使用一个实例,具体如下: 1. 设置断点 1 2 3 (gdb) b GenVedioSeekPoint Breakpoint 1 at 0x402e58: file GenIndex.cpp, line 140. (gdb) 2. 利用commad自定义断点操作 1 2 3 4 5 6 7 (gdb) command 1 Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >p *pstPktHead >continue >end (gdb) 3. 设置gdb log信息输出到指定文件 1 2 3 4 5 (gdb) set logging file genindex.txt (gdb) set logging on Copying output to genindex.txt. (gdb) set pagination off (gdb) 4. 开始或继续执行程序 1 (gdb) run 有输出信息如下: ...

August 28, 2015