[步骤] Linux 命令的监控 (audit 版)

正文:

步骤一:添加监控命令的 audit 规则

1.1 添加监控命令的 audit 规则的格式

-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


补充:这里以
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 解决使用 setfacl 命令时报错 “setfacl: …… : Operation not supported”

报错代码:

setfacl: ......: Operation not supported

解决方法 (添加 acl 参数):

临时解决方法(临时在挂载时添加 acl 参数):

# mount -o remount,acl /mnt

(补充:这里以给挂载的 /mnt 目录添加 acl 参数为例)

永久解决方法(永久在挂载时添加 acl 参数):

# vi /etc/fstab

将部分内容修改如下:

......
/dev/sda5 /mnt xfs defaults,acl 0 0
......

(补充:这里以给从硬盘 /dev/sda5 挂载到 /mnt 目录的目录添加 acl 参数为例)

[步骤] RHEL Relax-and-Recover (ReaR) 的使用 (备份系统)

注意:

默认情况下 ReaR 创建的备份只恢复存储的布局和启动加载器,不恢复实际的用户数据和系统文件

正文:

步骤一:安装 Relax-and-Recover (ReaR)

# yum install rear

步骤二:配置 Relax-and-Recover (ReaR)

2.1 案例一:配置 Relax-and-Recover (ReaR) (同时产生 2 份备份文件)

# vim /etc/rear/local.conf

创建以下内容:

......
OUTPUT=ISO
OUTPUT_URL=file:///tmp/rescue_system/


补充:这里以
1) 以 ISO 的格式存储备份 (我们可以选择 ISO 格式或 USB 格式,分别用于 ISO 引导或 USB 引导)
2) 将备份存储在本地 /tmp/rescue_system/ 目录为例


注意:这样的设置会创建 2 个备份文件:
1) 第 1 个配置文件会在用户设置的本地目录 /tmp/rescue_system//rear-localhost.iso 里
2) 第 2 个配置文件会在 Relax-and-Recover (ReaR) 默认的本地目录 /var/lib/rear/output/ 里

2.1 案例二:配置 Relax-and-Recover (ReaR) (只产生 1 份备份文件)

# vim /etc/rear/local.conf

创建以下内容:

......
OUTPUT=ISO
BACKUP=NETFS
OUTPUT_URL=null
BACKUP_URL="iso:///tmp/rescue_system/"
ISO_DIR="output location"


补充:这里以
1) 以 ISO 的格式存储备份 (我们可以选择 ISO 格式或 USB 格式,分别用于 ISO 引导或 USB 引导)
2) 将备份存储在本地 /tmp/rescue_system/ 目录为例

步骤三:创建救援系统

# rear -v mkrescue
......
Wrote ISO image: /var/lib/rear/output/rear-rhel8.iso (125M)
Copying resulting files to file location


注意:当出现以下内容时,则代表备份成功
……
Wrote ISO image: /var/lib/rear/output/rear-rhel8.iso (125M)
Copying resulting files to file location

参考文献:

https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-relax-and-recover_rear