linux - [Solved-5 Solutions] Remove a symlink to a directory - ubuntu - red hat - debian - linux server - linux pc



Linux - Problem :

How to remove a symbolic link to a directory ?

Linux - Solution 1:

# this works
rm wiki
# versus
rm wiki/
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 2:

rm should remove the symbolic link.

skrall@skrall-desktop:~$ mkdir bar
skrall@skrall-desktop:~$ ln -s bar foo
skrall@skrall-desktop:~$ ls -l foo
lrwxrwxrwx 1 skrall skrall 3 2008-10-16 16:22 foo -> bar
skrall@skrall-desktop:~$ rm foo
skrall@skrall-desktop:~$ ls -l foo
ls: cannot access foo: No such file or directory
skrall@skrall-desktop:~$ ls -l bar
total 0
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 3:

Assuming it actually is a symlink,

$ rm -d symlink
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 4:

  • Use rm symlinkname but do not include a forward slash at the end (do not use: rm symlinkname/).

Linux - Solution 5:

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.


Related Searches to - linux - linux tutorial - Remove a symlink to a directory