请谨慎使用你的root权限

本身来公司1年多了,管的系统早就烂熟于心。真是到了出了什么问题闭着眼睛都知道是错在哪。并且本身平时在服务器上操做当心谨慎。历来不会有什么问题。今天下午,想把服务器上的东西备份一下。而后从远程传了一些东西到主服务器上的根下。用完以后准备把它删了。不知道脑子里在想什么。我只是想删除一个目录而已。可是直接打出了rm -rf *的命令。回车的那一瞬间,提示linux

wKiom1i9DUHiX0jqAABHnTkkMpc697.png

虽然删了我知道怎么恢复。可是当时身体立马发热,感受头上冒汗。立马按住ctrl+c中止。中止之后也没有用,由于执行命令已经提示没有那个文件或目录了。没办法,我先从其它服务器上把/bin下的东西都拷了过来。而后查看下的文件和查看磁盘占用率的时候,发现大部分东西还在。冷静下来之后。想一想怎么收尾。缓存

首先查看了下数据被删的状况,看了下磁盘利用率没删多少bash

wKioL1i9EA-D4pfQAAB0Q2wRosM593.png但仍是不放心,模拟了一下删除根的过程服务器

wKioL1i9EOGCjsibAAAcoHzVGUU939.png

发现,应该是先删除bin,而后删boot,而后删除dev。bin已经恢复了。boot系统提示正在运行,没法删除。而后我就及时中止了。可是查看boot目录的时候发现什么东西都没有了,那应该是在内存中的缓存了。若是重启的话确定是起不来的ide

[root@rsync boot]# mkdir /boot/grub/
[root@rsync boot]# cp /usr/share/grub/x86_64-redhat/* boot/grub/
[root@rsync boot]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0)"...  27 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
[root@rsync boot]# yum -y install kernel-*
如下步骤还没开始执行,等服务器不忙的时候进行重启
四、reboot
五、系统会停留在grub界面上输入如下命令
kernel /vmlinux-2.4.20-8 ro root=LABEL=/
initrd /initrd-2.4.20-8 ro root=LABEL=/
六、boot

那么就是说如今若是重启能起来的话,应该是没有什么问题了。此次事件呢,总算是有惊无险。但愿你们引觉得戒。不要大意。以为本身没什么问题。尽可能不要去服务器上操做。若是必须使用普通用户,须要权限的时候sudo过去,而后执行命令的时候查看确认一下再进行删除,要否则出了问题,只能卷铺盖走人了blog

相关文章
相关标签/搜索