PDA

View Full Version : [ubuntu] Dangerous commands



Pandiani
November 9th, 2008, 09:33 PM
Hello, I have read about executing dangerous commands but I'd like to know more.
For example if I'm working in some directory I created, say /home.../mydir
and execute this command: rm -rf *, does this means I'll erase everything on my computer, not just all files in my current working directory?
What is the difference between rm -rf / and rm -rf .?
Will second command remove only contents of my working directory?

Thank you very much for your help.

DrDagostino1
November 9th, 2008, 09:38 PM
rm -rf * will erase all the files in your current directory.
rm -rf /* and rm -rf / will erase everything on your computer.
I'm not sure what rm -rf . will do though.

kernelhaxor
November 9th, 2008, 09:54 PM
I'm not sure what rm -rf . will do though.

rm -rf . will erase the current directory and all the files and sub-directories inside the current directory

lukjad007
November 9th, 2008, 09:58 PM
I hear the
sudo rm -rf / is disabled in Hardy and up. DON'T try it though. I ran this in Feisty for 2 secs and it destroyed my Compy.

jflaker
November 9th, 2008, 10:09 PM
Since some troll had a newbie run a command while "trying to help", I put a warning in my signature..... understand WHAT you are doing and WHY....

You should always investigate any command before you execute it....plenty of resources on the internet.

Matthewthegreat
November 9th, 2008, 10:14 PM
I have been wanting to see what this does first hand. If I run rm -rf / in a virtual machine if will only destroy the guest and not the host, Right?

jpeddicord
November 9th, 2008, 10:16 PM
rm -rf . will erase the current directory and all the files and sub-directories inside the current directory

`rm -rf .` will actually fail with:

rm: cannot remove directory `.'

because that would leave you with a nonexistent working directory. :)

jpeddicord
November 9th, 2008, 10:18 PM
I have been wanting to see what this does first hand. If I run rm -rf / in a virtual machine if will only destroy the guest and not the host, Right?

Correct, providing you do not have anything on a shared resource between the host and guest. Be sure to detach the guest from any network connections before trying it. (I wouldn't recommend trying it at all, really. Here's a video if you really want to see. (http://www.youtube.com/watch?v=wWOjmvWPRvQ))

pirattrev
November 9th, 2008, 10:23 PM
if you are going to erase anything important, i think it'll ask for a password first. Just don't give it unless you're sure.

jpeddicord
November 9th, 2008, 10:27 PM
if you are going to erase anything important, i think it'll ask for a password first. Just don't give it unless you're sure.

Not if you've run a command involving root privileges within the past 15 minutes. `sudo rm` will ask for your password because of the `sudo` bit to elevate privileges. But, it will remember your password for fifteen minutes afterwards, so it might not always ask.

In short, be wary of any commands you type in, folks. :)

Pandiani
November 10th, 2008, 08:35 PM
Thank you guys for your help and explanations.
Since these commands are risky I'll not try to execute them. However, I cannot understand how I can destroy my files and folders that way. I think that most modern operating systems don't allow such easy deletions of system files.
For example, system win XP can be formated only from bootable CD and appropriate menu.

Thanks again