> cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-6.4.0-150600.23.50-default root=/dev/mapper/vg-lv resume=/dev/disk/by-uuid/52g36p8s-29l6-2g4l-meqo-5o30l48s4839 splash=silent quiet mitigations=auto audit_backlog_limit=8192 audit=1 rd.shell=0 showopts LANG=C crashkernel=186M,high
[步骤] Linux 最新软件升级的检查
正文:
内容一:通过 yum 日志查看
# cat /var/log/yum.log
内容二:通过 rpm 命令查看
# rpm -qa --last
或者:
# rpm --query --all --last
补充:查看曾经通过 dnf 命令或者 yum 命令升级的记录
# dnf history
或者:
# yum history
[步骤] Linux 命令的监控 (audit 版)
正文:
步骤一:添加监控命令的 audit 规则
1.1 添加监控命令的 audit 规则的格式
配置文件格式:
-w <command> -p x -k <search_key>
命令格式:
# auditcl -w <command> -p x -k <search_key>
(
补充:
1) 这里的 <command> 是要监控的命令
2) 这里的 <search_key> 是个标识,用于简化在 audit 日志里搜索此命令
)
1.2 添加监控命令的 audit 规则的案例
配置文件的案例:
-w /usr/bin/rm -p x -k rm_command
命令案例:
# auditcl -w /usr/bin/rm -p x -k rm_command
(
补充:这里以
1) 监控 /usr/bin/rm 命令
2) 标识是 rm_command 为例
)
步骤二:让刚刚添加的规则生效
2.1 合并新添加的 audit 规则
# augenrules
2.2 重启 auditd 服务
# service auditd restart
步骤三:查看新添加的规则
# auditctl -l
步骤四:查看某个表示的 audit 日志
# ausearch -k rm_command
(补充:这里以查看标识为 rm_command 的 audit 日志为例)
参考文献:
https://access.redhat.com/solutions/3401281
[命令] Linux 命令 loginctl 的使用 (查看和管理所有 SSH 登录会话\进程)
内容一:查看所有 SSH 登录会话\进程
# loginctl -a
SESSION UID USER SEAT TTY
27 1001 mingyuzhu pts/0
(
补充:从输出结果可以看出
1) 会话\进程的 SESSION 号码为 27
2) 创建会话\进程的用户 UID 是 1001
3) 创建会话\进程的用户是 mingyuzhu
4) 创建会话\进程的 SEAT TTY 是 pts/0
)
内容二:关闭某个 SSH 登录会话\进程
# loginctl terminate-session 27
(补充:这里以关闭 SESSION 号码是 27 的会话\进程为例)
内容三:批量关闭某个用户通过 SSH 登录的所有会话\进程
3.1 批量关闭某个用户通过 SSH 登录的所有会话\进程 (显示输出结果)
# loginctl -a | grep mingyuzhu| awk '{print "loginctl terminate-session "$1;system("loginctl terminate-session "$1"")}'
3.2 批量关闭某个用户通过 SSH 登录的所有会话\进程 (不显示输出结果)
# loginctl -a | grep mingyuzhu| awk '{print "loginctl terminate-session "$1;system("loginctl terminate-session "$1"")}' > /dev/null
或者:
# loginctl -a | grep mingyuzhu| `awk '{print "loginctl terminate-session "$1;system("loginctl terminate-session "$1"")}'`
[排错] Linux 解决使用 authselect apply-changes 命令时报错 “[error] [……] has unexpected content!”
报错代码:
[error] [/....../system-auth] has unexpected content!
[error] [/....../password-auth] has unexpected content!
[error] [/....../nsswitch.conf] has unexpected content!
[error] Unexpected changes to the configuration were detected.
[error] Refusing to activate profile unless those changes are removed or overwrite is requested.
Some unexpected changes to the configuration were detected. Use 'select' command instead.
解决方法 (创建新的 authselect 文件):
步骤一:移走原来的 authselect 文件
# mv /etc/authselect/custom/password-policy /etc/authselect/custom/password-policy-backup
步骤二:创建新的 authselect 的文件
# authselect create-profile password-policy -b sssd --symlink-meta --symlink-pam
步骤三:使用新创建的 authselect 文件
# authselect select custom/password-policy with-sudo with-faillock without-nullok with-mkhomedir --force
步骤四:启用 oddjob 服务
# dnf install oddjob ; systemctl enable --now oddjobd.service
步骤五:启用新的 authselect 文件
# authselect apply-changes