On Thu, Mar 28, 2002 at 08:29:09AM +1100, Simon Bryan wrote: > Have been caught by this myself, it is the man page that says to use -d for > directories but it never works for me either. > Just what is the -d option for?
There are two system calls: unlink() and rmdir() rmdir (surprise) uses the system call rmdir(). rm -d uses the system call unlink() You -should- always use rmdir() to remove a directory and not unlink(). That is why you can only call unlink() on a directory when you are root, even if you own the directory you are trying to unlink. Thus you should only use rm -d (unlink) on a directory if you know what you're doing. I don't know what I'm doing, so I use rmdir. Also, rmdir will not let you remove a directory unless it is empty, unlink will, which is a bad thing: >From GNU file utilities: http://www.gnu.org/manual/fileutils-3.16/html_node/fileutils_38.html Because unlinking a directory causes any files in the deleted directory to become unreferenced, it is wise to fsck the filesystem after doing this. >From perldoc -f unlink: Note: unlink() will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are met, be warned that unlinking a directory can inflict damage on your filesystem. Use rmdir() instead. I'm not even sure why there is an option to call unlink() on a directory. If you would like to be more confused, check out: http://www.scit.wlv.ac.uk/~jphb/spos/notes/calls/unlink.html Regards, Chris -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
