tina conf type details -a des iptable pass 进程
shell 脚本第四篇--常用小脚本
1,将系统进程按内存占用大小排列显示出来
# ps -e -o "%C : %p : %z : %a"|sort -k5-nr
2,将系统进程按 CPU 占用大小排列显示
# ps -e -o "%C : %p : %z : %a"|sort -nr 或# ps aux --sort -rss
3,查找当前目录下占用为 0 字节的文件并删除
# find ./ -type f -size 0 -exec rm -rf {}\;
#此命令不要用于对根目录 0 字节文件的操作
4,匹配某文件中某一行并进行内容替换
#sed -i '/Root/s/no/yes'/etc/ssh/sshd_config #先匹配到 Root,再将此行 no 替换为 yes
5,TCP 抓包工具分析 80 端口数据流
# tcpdump -c 10000 -i eth0 -n dst port 80
6,删除所有空目录
# find /data -type d -empty -exec rm -rf {};
#最好不要在 / 目录下执行此命令
7,将来自 80 端口的请求转发到 8080 端口
#iptables - A PREROUTING - p tcp - m tcp - dport80 - j DNAT - to - destination 127.0.0.1 : 8080 8,
通过 apache 访问日志 access.log 统计 IP 及其访问的次数,按访问量列出前 10 名
# cat access.log | awk '{print $1}' |sort| uniq -c |sort -rn |head -10
9,锁定关键文件,防止被恶意篡改 || 解除锁定为 chattr -i
# chattr +i /etc/passwd chattr +i /etc/inittab
10,更改文件描述符大小为最大值 65535 下次登录生效,查看文件描述符值大小
#echo '* - nofile 65535' >> /etc/security / limits.conf;#ulimit - n 11,
通过 ssh 通道同步 1.105 的 / etc 下的 hosts 文件到本机 /data 目录下
# rsync -avz -e 'ssh -p 22' root@192.168.1.105:/etc/hosts /data/
12,杀掉 80 端口相关的进程
# lsof -i :80|grep -v "PID"|awk '{print"kill -9",$2}'|sh
13,取出 / etc/passwd 文件中 shell 出现的次数,
shell 指后面 / bin/bash,/sbin/nologin
#cat / etc / passwd | awk - F: '{print $7}' | sort | uniq - c 14,
在目录 / tmp 下找到 100 个以
a
开头的文件,然后把这些文件的第一行保存到文件
file
中
# find /tmp -type f -name "a*" | head -n 100 | xargs head -q -n 1 >> file
15,防攻击脚本,企业实用小脚本 http://blog.csdn.net/linuxlsq/article/details/52606408
shell 脚本第四篇--常用小脚本
来源: http://www.bubuko.com/infodetail-2466168.html