Remove a symlink to a directory
# this works:rm foo# versus this, which doesn't:rm foo/
Basically, you need to tell it to delete a file, not delete a directory. I believe the difference between rm
and rmdir
exists because of differences in the way the C library treats each.
At any rate, the first should work, while the second should complain about foo being a directory.
If it doesn't work as above, then check your permissions. You need write permission to the containing directory to remove files.
use the "unlink" command and make sure not to have the / at the end
$ unlink mySymLink
unlink() deletes a name from the file system. If that name was the last link to a file and no processes have the file open the file is deleted and the space it was using is made available for reuse.If the name was the last link to a file but any processes still have the file open the file will remain in existence until the last file descriptor referring to it is closed.
I think this may be problematic if I'm reading it correctly.
If the name referred to a symbolic link the link is removed.
If the name referred to a socket, fifo or device the name for it is removed but processes which have the object open may continue to use it.
rm should remove the symbolic link.
skrall@skrall-desktop:~$ mkdir barskrall@skrall-desktop:~$ ln -s bar fooskrall@skrall-desktop:~$ ls -l foolrwxrwxrwx 1 skrall skrall 3 2008-10-16 16:22 foo -> barskrall@skrall-desktop:~$ rm fooskrall@skrall-desktop:~$ ls -l fools: cannot access foo: No such file or directoryskrall@skrall-desktop:~$ ls -l bartotal 0skrall@skrall-desktop:~$