Delete a Symbolic Link?



I have encountered this problem a couple of times and need to know what it
is that I'm doing wrong. I often create a symbolic link in my /html folder
to link to the docs for FreeBSD or other important stuff. When I need to
erase this link and I execute the rm -r ./name_of_link it not only erases
the link, it erases the file or directory of files the link pointed to. This
is not what the manpage on rm says is supposed to happen.

Many of you won't believe me on this so here is the printout of the screen
that I captured while doing this. You can see that in the /usr/local/pgsql
directory there was a directory called doc and I linked to it in my /html
directory. First I tried to be safe and just used rm without the -r switch.
When that did not work, I used the -r switch and poof, the
/usr/local/pgsql/doc directory vanished along with the link.

localhost# ll /usr/local/pgsql/
total 12
drwxr-xr-x 2 root wheel 512 Oct 19 13:28 bin
drwxr-xr-x 3 root wheel 512 Oct 19 13:28 doc
drwxr-xr-x 6 root wheel 512 Oct 19 13:28 include
drwxr-xr-x 3 root wheel 1536 Oct 19 13:28 lib
drwxr-xr-x 4 root wheel 512 Oct 19 13:26 man
drwx------ 8 postgres postgres 512 Mar 7 19:53 pgdata
drwxr-xr-x 3 root wheel 512 Oct 19 13:28 share


localhost# ll
total 4
lrwxr-xr-x 1 root wheel 20 Oct 19 14:33 PostgreSQL-8.0.4 ->
/usr/local/pgsql/doc
lrwxr-xr-x 1 root wheel 37 Jan 31 16:11 Samba-3.0.21b ->
/usr/src/samba-3.0.21b/docs/htmldocs/
drwxr-xr-x 5 root wheel 512 Mar 10 13:16 myfolder
drwxr-xr-x 2 root wheel 512 Mar 3 16:55 morestuff

localhost# rm PostgreSQL-8.0.4/
rm: PostgreSQL-8.0.4/: is a directory

localhost# rm -r PostgreSQL-8.0.4/

localhost# ll /usr/local/pgsql/
total 12
drwxr-xr-x 2 root wheel 512 Oct 19 13:28 bin
drwxr-xr-x 6 root wheel 512 Oct 19 13:28 include
drwxr-xr-x 3 root wheel 1536 Oct 19 13:28 lib
drwxr-xr-x 4 root wheel 512 Oct 19 13:26 man
drwx------ 8 postgres postgres 512 Mar 7 19:53 pgdata
drwxr-xr-x 3 root wheel 512 Oct 19 13:28 share

The manpage for rm says this command is only supposed to erase the link not
the object the link points to. What am I doing wrong here?


.



Relevant Pages

  • Re: Diskless Boot Problem
    ... > Hosts on localhost: ... It's ok if you read the manpage to see what interesting options there ... Exports list on localhost: ...
    (freebsd-questions)
  • RE: Getopt::Std producing unexpected results
    ... perldoc Getopt::Std ... With your command line: ... First the '-h' switch is processed and 'localhost' is ... Next the '-l' switch is processed and 'file' is assigned to ...
    (perl.beginners)