前言:熟练掌握常用的Linux命令,可以提高生产力,研究问题的能力。常用命令包括:文件操作,系统查看,GCC命令,GDB调试等。这些都在系统开发中起到很重要的作用。
Linux常用命令
file-文件常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ls /etc/a*.confgrep "#define container_of" -R . diff /etc/service tmp cat filecat file | wc -ltail -n 10 out.log (-f 动态模式)tail -n 10 out.log -fls -lh file a.out du abc.c/directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 mkdir -p a/b/c touch a.txt1n -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh chmod a+x a.out chown root a.outchmod u+s mysu
system-系统常用命令
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 ulimit -a strace ./a.out time ./a.out export ps axf ps axm ps axj ps ax -L pstree pmap p_id kill -lkill pidipcs
network-网络查看
1 2 3 4 5 6 7 8 9 10 11 12 ip addr ip add sh ip ro sh ip ro add default via 192.168.1.125 netstat -anu netstat -ant
gcc-编译常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 gcc -E hello.c gcc -E hello.c > hello.i gcc -S hello.i gcc -c hello.s gcc hello.o -o hello gcc hello.c gcc hello.c -o myhello make hello objdump -d a.out strace -f gcc a.c strace -f gcc a.c 2>&1 | grep execve strip test_sqlist
gdb-调试器常用命令
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 28 29 30 31 32 gdb a.out run/r starti layout asm si info registers bt info inferiors print /p $rdx target record-full watch $rax watch *0x7c00 rsi layout src set scheduler-locking on thread 1
Vps+科学上网
v2ray和xray
1 source <(curl -sL https://multi.netlify.app/v2ray.sh) --zh
1 2 3 4 5 6 systemctl stop firewalld.service systemctl disable firewalld.service sudo ufw disable
安装tls
1 curl https://get.acme.sh | sh
1 2 mkdir -p /usr/local/bin1n -s/root/.acme.sh/acme.sh /usr/local/bin/acme.sh
1 acme.sh --set-default-ca --server letsencrypt
1 acme.sh --issue -d freeqing.dpdns.org --standalone -k ec-256
1 acme.sh --issue -d freeqing.dpdns.org --standalone -k ec-256 --listen-v6 --insecure
1 acme.sh --installcert -d freeqing.dpdns.org --ecc --key-file /etc/v2ray/server.key --fullchain-file /etc/v2ray/server.crt
ssh免密登录
检查现有 SSH 密钥(可选)现代、更推荐的 Ed25519 算法
1 ssh-keygen -t ed25519 -C "your_email@example.com"
将 SSH 密钥添加到 ssh-agent(管理密钥)
1 2 3 eval "$(ssh-agent -s) " ssh-add ~/.ssh/id_ed25519
1 2 cat ~/.ssh/id_ed25519.pub | clip