Results 1 to 10 of 11
Would this actually delete the entire hard drive? I know it would remove most things but how could rm remove itself?...
- 09-13-2007 #1
rm -rf /
Would this actually delete the entire hard drive? I know it would remove most things but how could rm remove itself?
Linux User #453176
- 09-13-2007 #2
Well, obviously it won't delete the kernel as it is in use (and if I recall the current running kernel is protected). The same goes for some of the system files. Nonetheless, it will delete files that are required for functionality. So, in short, yes, it'll ruin your installation.
I've never attempted to recover anything from a hard drive after this command was issued. It was just always fun to watch the thing go bye-bye only to start the long, tedius process of reinstalling the Operating System. But then again, that's the fun part isn't it?
- 09-13-2007 #3
Yeah, I knew it would ruin the installation. I was just wondering about what would be left behind after
Linux User #453176
- 09-13-2007 #4
Well, like I said Kieren, it will continue to delete files as permitted by the kernel and the user's permissions. So, I suppose it would leave intact everything that wasn't wiped before the crash.
You ought to try it! No, seriously, test it out in Bochs or QEMU. Then mount the image file as a loopback device and see what you can get out of it.
- 09-13-2007 #5
I think I might do when I get some time. I think I have a small HDD somewhere I can test it on
Linux User #453176
- 09-13-2007 #6
- 09-13-2007 #7
- 09-13-2007 #8
Ah, good point!
I might just set up a spare computer with DSL on it to test it. I was thinking of a little project of making a case out of something. Was just reading Envador.com | Innovative concept cases which looks quite cool and I do have an old guitar at home I could use...Linux User #453176
- 09-13-2007 #9
- 09-13-2007 #10
rm can indeed remove itself.
When a program is executed, its instructions and environment are loaded onto the stack and processed. The executable file that you ran doesn't actually need to exist any longer. For instance, try running this script:
The last echo statement will appear, despite the fact that the script has now vanished. Doing the same thing in C (deleting the binary) performs the same effect.Code:#!/bin/bash echo "My filename is $0" rm "$0" echo "I'm still here!"
DISTRO=Arch
Registered Linux User #388732


Reply With Quote

