linux安全

# 查看过去10天改动过的conf配置
find / -mtime -10 -type f -name \*.conf
# 查看异常操作记录
cat /root/.bash_history
# 查看拒绝和接收的记录
cat /var/log/secure
# 查看是否有随机启动的服务
cat /etc/rc.local
# 重点关注半夜登陆的可以ip
last
# 查看是否存在uid 0,gid 0非root用户
cat /etc/passwd
# 查看某个端口加载情况
lsof -i:端口
# 查看网卡RX(接收包)和TX(对外发包)
watch ifconfig
#记录登录失败的ip
cat /var/log/btmp

方法1,可以显示详细的端口连接信息:
lsof -i:18180
方法2,直接显示某个端口连接的数量:
netstat -an |grep 'ESTABLISHED' |grep -i '18180' |wc -l

在日常工作中,我们可以用shell组合命令来查看服务器的TCP连接状态并汇总,命令如下:
 
netstat -an|awk '/^tcp/{++S[$NF]}END{for (a in S)print a,S[a]}'
#统计 TCP连接数 命令:

netstat -an |grep 'ESTABLISHED' |grep 'tcp' |wc -l  

 

posted @ 2020-07-24 22:44  Macoffee  阅读(91)  评论(0编辑  收藏  举报