Ubuntu运维命令
1 创建用户
sudo adduser <name>
2 赋予用户超级权限
sudo adduser <name> sudo
3 查看端口和进程监听对应
sudo netstat -tlpn
4 查看防火墙状态
sudo ufw status
关闭状态:inactive
开启状态:active
5 关闭防火墙
sudo ufw disable
6 开启防火墙
sudo ufw enable
7 查看TCP连接处于各阶段的总数
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
8 查看全部TCP连接
netstat -natp
其中-a表示all、-n表示numeric直接显示IP、-t表示TCP、-p表示programs显示端口对应进程。
9 find查找
9.1 查找目录及其子目录的某一文件
由于一般查找是不知道名字的,只有模糊匹配。
find -name *.txt
9.2 只在当前目录
find -maxdepth 1 -name *.txt
不遍历子目录,深度设置为1。
9.3 当前目录下所有子目录
find -maxdepth 1 -type d
d表示dir目录;f表示file一般文件。
9.4 统计当前目录及子目录文件总数
find -type f | wc -l
wc是word count,-l是line,有多少行。