linux symbolic without - Remove a symlink to a directory
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.
I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it.
rm and get back
rm: cannot remove 'foo'.
rmdir and got back
rmdir: failed to remove 'foo': Directory not empty
I then progressed through
rm -rf and
sudo rm -rf
Then I went to find my back-ups.
Is there a way to get rid of the symlink with out throwing away the baby with the bathwater?
rm symlinkname but do not include a forward slash at the end (do not use:
rm symlinkname/). You will then be asked if you want to remove the symlink,
y to answer yes.
If rm cannot remove a symlink, perhaps you need to look at the permissions on the directory that contains the symlink. To remove directory entries, you need write permission on the containing directory.
On CentOS, just run
rm linkname and it will ask to "remove symbolic link?". Type Y and Enter, the link will be gone and the directory be safe.