常用命令

  1. 工具
    1. Git
    2. Clion-将Windows换行转换为Linux模式
    3. VIM&zsh设置
    4. Make设置install指定文件
    5. lsof iftop
    6. 安卓adb抓包
    7. 安装Prometheus

工具

Git

# 压缩两个提交
git rebase --interactive HEAD~2

# 将
# pick c6d7bf6 fix namespace bug
# pick 1c648d8 fix namespace bug
# pick 7c648d8 fix namespace bug
# 改为
# pick c6d7bf6 fix namespace bug
# s 1c648d8 fix namespace bug
# s 7c648d8 fix namespace bug

# 压缩所有提交
git rebase --interactive -root

# 更新所有submodule
# 首次运行
git submodule update --init --recursive
# 之后运行
git submodule foreach --recursive git pull origin master -f

Clion-将Windows换行转换为Linux模式

how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows

git config --global core.eol lf
git config --global core.autocrlf input

git rm -rf --cached .
git reset --hard HEAD

VIM&zsh设置

VIM

set expandtab
set ts=4
set shiftwidth=4
set sts=4
set tw=100
set number
set cinoptions=:0,g0,(0,w1
set backspace=indent,eol,start


" set smartindent
set autoindent
set cindent
set softtabstop=4
set tabstop=4

set enc=utf-8
set nocompatible
syntax on

set fileencodings=ucs-bom,utf-8,gb18030,latin1

set nobackup
set undofile
set undodir=~/.vim/undodir
if !isdirectory(&undodir)
    call mkdir(&undodir, 'p', 0700)
endif

if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif

set pastetoggle=<F2>

ZSH

plugins=(git zsh-autosuggestions zsh-syntax-highlighting autojump)

Make设置install指定文件

make install <name>

for-cmakes-install-command-what-can-the-component-argument-do

install(TARGETS main RUNTIME DESTINATION ./install_dir/ COMPONENT main)
add_custom_target(install_main COMMAND ${CMAKE_COMMAND} -DCOMPONENT=main -P ${CMAKE_BINARY_DIR}/cmake_install.cmake)

lsof iftop

# lsof
lsof -i tcp:10002 -P
-P 不解析端口号,直接显示

# iftop
-P 显示端口号
-N 不解析端口号

l 输入fileter,可以直接输入ip

安卓adb抓包

adb connect 127.0.0.1:port # (连接指定机器)
adb pull /sdcard/1.pcap . # (拉取文件到本地)
adb shell # (进入机器中 打开shell)
adb devices # (列出所有设备)
adb push tcpdump /sdcard/... # (推送文件)
# wireshark左下角的灯是可以点的,可以列出来可疑项目

安装Prometheus

docker run -d -p 9090:9090 -v /data/prometheus/prometheus.yml:/data/prometheus/prometheus.yml -v /data/prometheus:/data/prometheus --user root --name prometheus prom/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus