rm -rf $Home (was GNOME hangs)

Kwan Lowe kwan at digitalhermit.com
Sun Aug 6 18:55:34 UTC 2006


>>> .... I was advised to do something
>>> which turned out to be disastrous so NEVER EVER issue the following from
>>> a root shell
>>>
>>> rm -rf $Home/*
>>>
>>
>> Are you sure you executed the command above ? This would mean you
>> deleted the /root directory and all its contents. Are you sure you
>> didn't delete your personal home dir and everything in it ?

Actually as the above command is written, it would have deleted everything under /,
not /root. $Home is not set, but $HOME.

I've seen some scripts with the following:

LOGDIR=/var/log/myapp
cd $LOGDIR
rm -rf *

If for some reason LOGDIR is inaccessible then the script owners $HOME is likely to
be trashed. On some systems where root's home is not /root, then likely everything
in / gets trashed.


>> Anyway, I guess you've learned your lesson, don't just copy and execute
>> commands (especially rm commands) from a root shell.

Which is incredibly good advice for any system...
-- 
* The Digital Hermit   http://www.digitalhermit.com
* Unix and Linux Solutions   kwan at digitalhermit.com




More information about the fedora-list mailing list