Can't remove or change a directory

Mikkel L. Ellertson mikkel at infinity-ltd.com
Fri Nov 16 14:13:32 UTC 2007


Tony Nelson wrote:
> At 1:22 PM -0600 11/15/07, Mikkel L. Ellertson wrote:
>  ...
>> ...Did you know that
>> to remove a directory, you should use rmdir, and not rm? There is
>> also "rm -d <directory>", but that is limited to root, and should be
>> used with care.
> 
> What is the benefit of using rmdir rather than rm -rf, other than having to
> empty the directory first?  (I use two steps, ll dir followed by editing
> the command to be rm -rf.)
> 
Safety - you are less likely to remove things you did not mean to.
Just as your test makes sure you are deleting only what you want,
using rmdir makes sure you are removing an empty directory.

> I don't see any -d option to rm in man rm, info rm, or rm --help (all tests
> done as root!).
From "man rm" on FC6 (It looks like the later versions do not have it.):

-d, --directory
    unlink FILE, even if it is a non-empty directory (super-user
    only; this  works only if your system supports ‘unlink’ for
    nonempty directories)

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20071116/d439d278/attachment-0001.sig>


More information about the fedora-list mailing list