How do I delete softlink or symbolic link in Linux operating system using a command prompt?
You can use any one of the following command to remove symbolic links:
- rm - removes each given FILE including symbolic links
- unlink - deletes a single specified file name including symbolic links.
Delete Symbolic Link File
Use the following syntax:
rm linkname unlink linkname
Cd to /tmp
cd /tmp ln -s /etc/resolv.conf dns ls -l dns
Outputs:
lrwxrwxrwx 1 vivek vivek 16 2009-08-16 04:28 dns -> /etc/resolv.conf
Now delete dns symbolic link:
rm dnsOR
unlink dnsDelete Symbolic Link Directory
Use the following syntax:
rm linkDirName unlink linkDirName
Note: Avoid appending / at the end of linkDirName. Cd to /tmp:
cd /tmp ln -s /etc test ls -l test
Sample Output:
lrwxrwxrwx 1 vivek vivek 4 2009-08-16 04:31 test -> /etc
Now delete test symbolic link directory:
rm test
OR
unlink test
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 8 comments… read them below or add one }
Is there any way to automatically delete the links too on deletion of a file
say,
mainfile -> linkfile
now rm -f mainfile , should delete linkfile too ?? in RHEL it exists but points no where.
Hi ,
can you explain below thing
[root@localhost html]# unlink bugzilla-st/
unlink: cannot unlink `bugzilla-st/’: Not a directory
[root@localhost html]#
[root@localhost html]#
[root@localhost html]# rm bugzilla-st/
rm: cannot remove `bugzilla-st/’: Is a directory
Thanks&Regards,
Srinu
rm -R bugzilla-st/
what`s the result?
dont put slash at the end, use “unlink bugzilla-st” then it will work even i ahd the same problem,
thanks, the trailing slash was the issue for me too
1st delete the source file..
then remove the Link
Eg:
symlink file
test 1–> /opt/test
removing source file
# rm -Rf /opt/test
remove link
# unlink test1
enjoy……. :D
[root@localhost html]# unlink bugzilla-st/
unlink: cannot unlink `bugzilla-st/’: Not a directory
==> unlink bugzilla-st
thanks All , After removing slash it is working .