Tech Support > Operating Systems > UNIX / Variants > Deleting a hard link to a directory?
Deleting a hard link to a directory?
Posted by Philip White on November 23rd, 2007


Hi, all;

I don't know how, but a long time ago I made a hard link to a home
directory, like so:

$ ls -1i /
....
1224001 etc
2121601 home
2121601 hometest
767041 lib
....

Now I would really like to get rid of /hometest, but I have no idea how!
'rmdir' returns "rmdir: /hometest: Device or resource busy" (even though
'lsof' shows nothing as having any part of /hometest open), 'rm' tells me
that it's a directory, and 'rm -rf /homedir' is unacceptable for obvious
reasons.

Help!

--
PGP key: http://www.qnan.org/~pmw/pgp/public.asc

Posted by Barry Margolin on November 23rd, 2007


In article <fi7a18$ccv$1@registered.motzarella.org>,
Philip White <pmw+news@qnan.org> wrote:

Do you have an "unlink" command? This typically bypasses all the checks
and simply removes the link.

If not, try: perl -e 'unlink "/hometest"'

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Posted by Philip White on November 23rd, 2007


On Fri, 23 Nov 2007 15:58:39 -0500, Barry Margolin wrote:
I forgot to mention that I've tried that too. :/

# unlink hometest
unlink: cannot unlink `hometest': Is a directory

--
PGP key: http://www.qnan.org/~pmw/pgp/public.asc

Posted by Edward C. Otto III on November 23rd, 2007


Philip White wrote:
Have you tried the following steps?

1) Take susyem down to console prompt;
2) umount /home
3) rm -rf /hometest

Ed


Similar Posts