Linux服务器等保测评命令

最近公司等保,就罗列了一些测评命令,记录下

LANG="en_US.UTF-8" #临时设置utf8编码
ip addr #查看IP地址
ifconfig  #查看IP地址
dmidecode -s system-product-name #查看服务器是虚拟机还是物理机
cat /proc/version #查看版本信息
cat /etc/redhat-release #查看centos 版本
lsb_release -a #此命令也适用于所有的Linux发行版。 
uname -a #查看小版本
cat /etc/shadow #查看密码文件的信息 第一个:和第二个:之间有空说明空口令(*无法登录!被锁定)
cat /etc/login.defs | grep -E "PASS_*"| grep -v "^#" #查看密码有效期 Ubuntu也可以查看#############
cat /etc/pam.d/system-auth | grep -v "^#" | grep -E "pam_cracklib|pam_pwquality" #查看密码复杂度
cat /etc/pam.d/system-auth | grep -v "^#" | grep -v "^$" | head -n 1 #登录失败本机切换
cat /etc/pam.d/sshd | grep -v "^#" | grep -v "^$" | head -n 1 #登录失败-远程直连
cat /etc/security/pwquality.conf | grep -v "^#" | grep "=" #查看密码复杂度
cat /etc/pam.d/common-password    #Ubuntu查看密码复杂度策略 ################
cat /etc/pam.d/common-auth  #Ubuntu查看登录失败策略##############
cat /etc/passwd | grep -v "nologin" #查看用户的关键信息
cat /etc/group #查看用户组信息
cat /etc/login.defs | grep -E "PASS_*"| grep -v "^#" #查看全局策略
cat /etc/profile | grep -v "^#" | grep -v "^$" #查看全局变量
cat /etc/profile | grep TMOUT #查看超时时间参数TMOUT
cat /etc/ssh/sshd_config   #ClientAliveInterval 300 ClientAliveCountMax 3 意思是5分钟检查一次客户端响应,最多检查3次。如果3次都检查到客户端不响应,那么就认为ssh已经断开了 
chkconfig –list | grep telnet #列出telnet服务
ps aux | grep telnet | grep -v "color=auto" | grep -v "grep" #查看telnet服务
cat /etc/pam.d/login #登录失败策略  Ubuntu也可以查看 ##########################
cat /etc/pam.d/su #是否限制只有wheel组用户可使用su命令切换到root账户,查看auth required pam_wheel.so use_uid此行是否生效(未被注释)
cat /etc/ssh/sshd_config | grep PermitRootLogin #查看 root 用户是否可以远程链接
cat /etc/sudoers | grep -v "^#" | grep -v "^$" #查看是否限制了sudo命令的使用,如user ALL=(root) /usr/bin/passwd(user用户可使用sudo以root权限执行passwd命令)
ls -al /var/log   #查看日志文件夹
ls -al /etc/shadow /etc/passwd /etc/group /etc/xinetd.conf  /etc/rc.d/init.d /var/log/messages /var/log/wtmp  /var/run/utmp  /var/log/message  /var/log/secure  /var/log/audit/audit.log #查看访问级别
last | tail -n 20 #显示尾记录
last | head -n 20 #显示首记录
service rsyslog status | grep "running" #系统日志状态
service syslog status | grep "Active" #系统日志状态centos5之前版本
service auditd status | grep "running" #审计状态
who /var/log/wtmp     #查看服务器登录记录,核查审计范围是否覆盖每个用户
service firewalld status | grep "Active" #firewall状态
service nfs status | grep "Active"  #nfs状态
service samba status  | grep "Active" #samba状态
service iptables status | grep "Active" #查看iptable策略
ps aux | grep auditd | grep -v "color=auto" | grep -v "grep" #查看auditd状态
ps aux | grep rsyslog | grep -v "color=auto" | grep -v "grep" #查看rsyslog状态
cat /etc/audit/auditd.conf | grep -v "^#" | grep -v "^$" #配置文件
cat /etc/audit/rules.d/audit.rules #配置文件
cat /etc/logrotate.conf  | grep rotate  #日志保存几个月  默认 rote 4  默认保存4个月
cat /var/log/messages | tail -n 10 #messages #查看审计日志
cat /var/log/audit/audit.log | tail -n 10 #查看审计进程日志
cat /var/log/messages | head -n 10 #messages #查看审计日志
cat /var/log/audit/audit.log | head -n 10 #查看审计进程日志
cat /etc/rsyslog.conf   #查看日志外发配置
auditctl -s #auditctl状态
auditctl -l #查看定义规则
getenforce   #查看SELinux 模式是否开启
cat /etc/selinux/config | grep -v "^#" | grep -v "^$" #selinux配置
netstat -ntupl #查看端口
ss  -ntupl   #查看端口
netstat -nulp #查看端口
ps -aux #查看进程
ss -tuarp #查看所有tcp,udp,名称显示,显示pid
rpm -qa |grep patch #查看patch安装
rpm -qa | grep cracklib #查看是否安装了 pam_cracklib.so 模块
authconfig --test | grep hashing #查看加密算法
cat /etc/hosts.allow | grep -v "^#" | grep -v "^$" #查看防火墙允许策略
cat /etc/hosts.deny | grep -v "^#" | grep -v "^$" #查看防火墙禁止策略
iptables -L -nv #查看iptables规则-端口及地址限制
firewall-cmd --list-all #查看firewall规则
cat /etc/crontab #定时任务文件
crontab -l #定时任务(注意定时)
ping baidu.com -c4 #是否连接外网
ping 8.8.8.8 -c4 #是否连接外网
top -n 1 |head -n 3 |tail -n 1 | awk -F " " '{print $2 "%"}' #查看CPU占用率

free | head -n 2 | tail -n 1 | awk -F " " '{printf("%.1f%\n",$3/$2*100)}' #查看内存占用率

df -h | awk '$NF=="/"{print $5}'

top -n 1|awk -F'[,| ]+' /'%Cpu'/'{ printf("%s %.01f\n",strftime("[%Y-%m-%d %H:%M:%S]",systime()),100-$11); }' #查看CPU占用率

free | head -n 2 | tail -n 1 | awk -F " " '{printf("%.1f%\n",$3/$2*100)}' #查看内存占用率

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈苏漾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值