另类实验
疑问:在Linux启动后,执行 rm -rf / 删除所有目录及文件,系统还能运行吗?
环境建议:最好在虚拟机(如VMWare)中安装Linux系统进行测试,这样可以利用虚拟机的快照功能,随时可以恢复。
- 实验开始,以CentOS 7.6 Linux为测试环境。
Linux启动后,以root用户执行。提升需要增加:--no-preserve-root 参数,然后增加参数再试
复制代码
1
2
3
4
5[root@centosa ~]# rm -rf / rm: it is dangerous to operate recursively on ‘/’ rm: use --no-preserve-root to override this failsafe [root@centosa ~]# rm -rf --no-preserve-root /
然后增加参数再rm尝试。rm删除过程中提示了很多“rm: cannot remove”
删除完后,发现可用的命令有cd 、 pwd、export等命令。许多日常常用的命令都无法使用。甚至poweroff关机命令也无法运行只能强行关机。如下图( bash: sed: command not found 这句提示可忽略 )
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24...(省略)... ...(省略)... rm: cannot remove ‘/var/lib/nfs/rpc_pipefs/nfs’: Operation not permitted rm: cannot remove ‘/var/lib/nfs/rpc_pipefs/mount’: Operation not permitted rm: cannot remove ‘/var/lib/nfs/rpc_pipefs/lockd’: Operation not permitted rm: cannot remove ‘/var/lib/fwupd’: Device or resource busy rm: cannot remove ‘/tmp’: Device or resource busy rm: cannot remove ‘/usr’: Device or resource busy rm: cannot remove ‘/home’: Device or resource busy bash: sed: command not found [root@centosa /]# bash: sed: command not found root@centosa /]# df -m bash: df: command not found bash: sed: command not found [root@centosa ~]# cd / bash: sed: command not found [root@centosa /]# pwd / bash: sed: command not found [root@centosa /]# ls bash: ls: command not found bash: sed: command not found
- 进一步测试
重新找一个Linux环境,或者利用虚拟机的快照恢复到上步删除前。
Linux启动后,以root用户执行。 删除前,先执行一些命令,例如:cd 、pwd、vi、ls、top、ps、df、export、echo等。执行后,相当于把命令的内容加载到内存中。
复制代码
1
2
3
4
5
6
7
8
9
10
11[root@centosa tmp]# cd /etc/ [root@centosa etc]# pwd /etc [root@centosa etc]# vi /etc/passwd [root@centosa etc]# ls [root@centosa etc]# top [root@centosa etc]# ps [root@centosa etc]# df -m [root@centosa etc]# export [root@centosa etc]# echo "AAA"
然后再执行删除:rm -rf --no-preserve-root /
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21[root@centosa etc]# cd /etc/ bash: sed: command not found [root@centosa etc]# pwd /etc bash: sed: command not found [root@centosa etc]# vi /etc/passwd bash: /usr/bin/vi: No such file or directory bash: sed: command not found [root@centosa etc]# ls bash: /usr/bin/ls: No such file or directory bash: sed: command not found [root@centosa etc]# top bash: /usr/bin/top: No such file or directory bash: sed: command not found [root@centosa etc]# ps bash: /usr/bin/ps: No such file or directory bash: sed: command not found entosa etc]# echo "AAA" AAA bash: sed: command not found
能用的还是那几个命令(多了echo命令可以用),其他命令还是不能用。但提示已经变成了:No such file or directory
- 结论:
- 可以删除全部磁盘内容(除非明确提示不能删),删除后系统处于不可用状态。
- 已经加载到内存中的可以使用(注意两次使用提示的变化)。但是有些命令执行过程中,需要访问磁盘,只要访问磁盘,就无法执行。
- 日常使用 rm -rf / Linux有保护性提示,不容易误操作。
最后
以上就是碧蓝纸飞机最近收集整理的关于另类实验:Linux启动后,rm删除全部磁盘的效果的全部内容,更多相关另类实验:Linux启动后,rm删除全部磁盘内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复