1. grep 查询筛选
grep -E -v “^#|^$” /tmp.txt 查找/tmp.txt文件内除了以#号开头和空行的行
-v 是反向查询 -E正则表达式 “^#” 以#号开头的行 “^$”表示首尾 即空行。
grep --color -iRn damon /root 查找/root目录下所有文件及子文件内包含damon字样的行
--color 高亮 -i 忽略大小写 -R 递归 -n 显示行号
2. nohup 后台
nohup damon.sh 将脚本不中断的放到后台运行
3. lsof 查看进程
lsof /tmp 查看当前哪些进程在占用/tmp目录
losf -i:22 查看哪些进程在使用端口
losf –u root 查看用户当前打开哪些文件
4. pssh 批量机器操作
pssh -i -H ‘ip1 ip2’ uptime 在ip1和ip2机器上执行uptime命令
pssh -i -h ip.txt uptime 在ip.txt 文件内的所有机器上执行uptime命令
pscp -h ip.list damon.txt /tmp 将damon.txt 文件拷贝到ip.list内所有机器的/tmp目录下
pslurp -h ip.list -L /tmp /root/damon.txt damon.txt 将ip.list内所有机器的/root/damon.txt 文件复制到本机的/tmp目录下
5. iostat 查看磁盘I/O
iostat 查看当前I/O状态
iostat sda 2 5 收集指定磁盘sda的IO信息,每两秒一次,共5次,可以加-k/m代表单位。
6. Yum Aliyun
baseurl=https://mirrors.aliyun.com/epel/6/x86_64/
根据命令查包 yum provides “*mkpasswd”
7. NTP服务
配置文件 /etc/ntp.conf
替换ntp server为 server ntp1.aliyun.com iburst 和 server ntp2.aliyun.com iburst
重启服务,开机自启 ntpd chkconfig ntpd on
查询NTP服务器时间 ntpdate -q ntp1.aliyun.com
检查NTP同步状态 ntpq -p
8. DNS查询
dig www.aliyun.com 直接查看域名信息,ip cname等
dig -x ip 反向查询,通过ip查域名
dig +trace www.aliyun.com 查看过程
nslookup 域名/ip 正向/反向查询
9. 网络配置
查看ip信息 ifconfig -a
查看路由表 netstat -rn 或 route -a
10. 日志
11. 查发行版本lsb_release -a