linux 常见命令
文本处理类
- less
- more
- cat
- head
- tail
- awk
- cut
- grep, egrep, fgrep #print lines that match patterns, egrep & fgrep deprecated
-- grep -v abc /var/log #打印不匹配的行
-- grep -c abc -r /var/log #显示每个文件有多少匹配的数量
-- grep -n abc /var/log #前面打印行号
-- grep -n -C 3 abc /var/log #context 信息前后各3行, 或者 -B (Before), -A (After)
-- grep -r abc /var/log #recursive - sort
- uniq
- wc
网络类:
- ip #查看管理设置网络地址, 路由等信息
-- ip link
-- ip add show
-- ip neighbor show
-- ip -h -s link
-- ip help
-- ip route help - ifconfig
- netstat
-- netstat -nlpt - nstat
- ss
- curl
- wget
- telnet
- nc
- traceroute
- mtr
- dig
- nslookup
- host
- ping
内存类:
- free -m
- vmstat
-- vmstat 1 3
磁盘类:
- df # 显示文件系统信息
- du # Summarize disk usage of the set of FILEs, recursively for directories
- iotop
- iostat
-- iostat -t -x
-- iostat -t -x 1 3
CPU 进程类
- lscpu
- mpstat
- top
- htop
- uptime
- ps
-- ps -U xiatian -l
-- ps --forest
-- ps H 16705 #显示特定进程的线程信息
-- ps -o ppid,pid,lwp,nlwp,%cpu,%mem,cputime,cmd,args k -%cpu H 16705 # 自定义输出列
系统设备类:
- dmesg Display or control the kernel ring buffer
- mount, umount
监控统计性能:
- sar #https://github.com/sysstat/sysstat
- vmstat
- dtrace
- systap
- ptrace
- strace
- ltrace
- iotop
- top
- iostat
系统软件管理类:
- rpm, yum
-- rpm -a -q #查看所有安装的包
-- rpm --last #查看最后安装的 - apt-get, apt-cache
系统其它类:
- w
- who
- whoami
- last
- mount/umount
- find
- cd, pwd, ls
- touch
- lsof
- which
- file
- chmod
- chown
- useradd