[内容] Linux 命令 rmdir (删除目录)

案例一:使用 rmdir 命令删除目录

# rmdir -p test

(补充:这里以删除目录 test 为例)

案例二:使用 rmdir 命令删除目录和其子目录

# rmdir -p test1/test2/test3

或者:

# rmdir --parents test1/test2/test3

或者:

# rmdir --parents test1/test2/test3 test1/test2 test1

(补充:这里以删除目录 test1/test2/test3,test1/test2 和 test1 为例)

[命令] Linux 命令 shred (删除目录或文件)

正文:

内容一:shred 命令的作用

shred 的作用是删除文件。和 rm 命令不同的是 shred 在删除前会通过多次 (默认 3 次) 覆盖的方式防止数据被删除


注意:
1) 多次覆写大文件会消耗较多时间和 I/O 资源
2) 由于 SSD 的磨损均衡技术,shred 在 SSD 上可能无法完全擦除数据

内容二:shred 命令的格式

# shred <option> <file>

内容三:shred 命令的选项

1) -n <覆写的次数>,设置覆写的次数
2) -z ,最后用零进行覆写,以隐藏 shred 命令的痕迹
3) -u ,覆写后删除文件
4) -v ,显示详细过程
5) -f ,强制写入,若需要则修改权限
6) -x ,不处理超过文件大小的块

内容四:shred 命令的案例

4.1 以指定覆写次数的方式删除文件

# shred -n 5 -v test.txt

(补充:这里以覆写 5 次的方式删除 test.txt 文件为例)

4.2 以随机覆写次数的方式删除文件

# shred --random-source=/dev/urandom -v test.txt

(补充:这里以随机覆写次数的方式删除 test.txt 文件为例)

补充:

补充一:使用 dd 命令删除文件

# dd if=/dev/zero of=test.txt bs=1M count=10

(补充:这里以每次容量是 1M,覆写文件 test.txt 10 次为例)

补充二:使用 wipe 命令删除文件

# wipe -r -q test.txt

(补充:以清除 test.txt 文件为例)

[内容] Linux 需要注意的文件权限 (RHEL 9 版)

正文:

内容一:需要注意的文件权限

/run/credentials/ 目录下以 system 开头的文件都是只读文件

# ls -l /run/credentials/
total 0
dr-x------ 2 root root 0 Aug 30 20:36 systemd-sysctl.service
dr-x------ 2 root root 0 Aug 30 20:36 systemd-tmpfiles-setup-dev.service
dr-x------ 2 root root 0 Aug 30 20:36 systemd-tmpfiles-setup.service
......

内容二:查看这些文件的详细信息

# man 8 systemd-tmpfiles
# man 8 systemd-sysctl.service
# man 5 systemd.exec
# man 7 systemd.system-credentials
......

参考文献:

https://access.redhat.com/solutions/7024041