LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Some Questions About Deleting Files (https://www.linuxquestions.org/questions/linux-newbie-8/some-questions-about-deleting-files-788013/)

Quakeboy02 02-09-2010 03:08 PM

Quote:

Originally Posted by MTK358 (Post 3858204)
I'm so confused :confused:

Howcome rm -rf .. doesn't delete the parent but rm -rf * does?

Where did you get the idea that "rm -rf *" does delete the parent?

MTK358 02-09-2010 03:43 PM

Quote:

Originally Posted by Quakeboy02 (Post 3858209)
Where did you get the idea that "rm -rf *" does delete the parent?

I hear so many stories of people accidentally typing "rf -rf *" as root and deleting the entire file structure.

halborr 02-09-2010 04:10 PM

Quote:

Originally Posted by MTK358 (Post 3858257)
I hear so many stories of people accidentally typing "rf -rf *" as root and deleting the entire file structure.

Could it be "rm -rf /*" or "rm -rf /" you're thinking of?

tredegar 02-09-2010 04:12 PM

Quote:

I hear so many stories of people accidentally typing "rm -rf *" as root and deleting the entire file structure.
Usually it's this mistake that causes the fatal error:

Code:

rm -rf / path/to/directory
Notice the accidental space between the "/" and "path"

So this is equivalent to rm -rf / and it probably never gets as far as
rm: cannot remove "path/to directory" : No such file or directory

So this is a bad thing to type as root. Used as your username, it'll "just" remove all the entries under your /home/username, and any files you may have in /tmp, so you are wiped out, but the system will still continue to function normally ( root can login, and re-create your account, if not the data it held ).

Backups are important.

I once hosed my system with (as root)
Code:

cd /home/tred/oldhome-with different-UID:GID
chown -R tred:tred *
# Noticed the .files hadn't been chown'd, so..
chown -R tred:tred .*

Thought it was taking rather too long. So I <CTRL>-C'd it.
System broken.

Can you work out why?

[Reinstall required (but no data lost). Lesson learnt :) ]

MTK358 02-09-2010 07:20 PM

Quote:

Originally Posted by tredegar (Post 3858285)
Usually it's this mistake that causes the fatal error:

Code:

rm -rf / path/to/directory
Notice the accidental space between the "/" and "path"

So this is equivalent to rm -rf / and it probably never gets as far as
rm: cannot remove "path/to directory" : No such file or directory

No, I'm pretty sure it was rm -rf *

Quote:

Originally Posted by tredegar (Post 3858285)
I once hosed my system with (as root)
Code:

cd /home/tred/oldhome-with different-UID:GID
chown -R tred:tred *
# Noticed the .files hadn't been chown'd, so..
chown -R tred:tred .*

Thought it was taking rather too long. So I <CTRL>-C'd it.
System broken.

Can you work out why?

[Reinstall required (but no data lost). Lesson learnt :) ]

No, I looked at it for a few minutes and couldn't figure it out.

Though I'm suspecting it might have something to do with the space in the filename.


All times are GMT -5. The time now is 02:27 PM.