How to Remove a Symbolic Link (Symlink) in Linux

A symbolic link (symlink) is a special type of file that points to another file or directory. It works like a shortcut, letting you organize and access files more efficiently. You can create symlinks with the ln command
.
This guide explains how to remove symbolic links in Linux using the rm, unlink, and find commands.
Quick Reference
| Task | Command |
|---|---|
| Remove a symlink | rm symlink_name |
| Remove with confirmation | rm -i symlink_name |
| Remove multiple symlinks | rm symlink1 symlink2 |
| Remove a symlink (unlink) | unlink symlink_name |
| Find broken symlinks | find /path -xtype l |
| Delete broken symlinks | find /path -xtype l -delete |
Before You Begin
To remove a symlink, you must have write permissions on the directory containing it. Otherwise, the command returns a permission-related error.
When you remove a symlink, the file or directory it points to is not affected. Only the link itself is deleted.
Use the ls -l
command to check whether a file is a symbolic link and see where it points:
ls -l /usr/bin/python3lrwxrwxrwx 1 root root 10 Aug 18 2024 /usr/bin/python3 -> python3.12The first character l indicates that the file is a symlink. The -> symbol shows the target file.
Remove Symbolic Links with rm
The rm
command removes files and directories.
To delete a symlink, invoke rm followed by the symbolic link name:
rm symlink_nameOn success, the command produces no output and exits with zero.
You can remove more than one symbolic link at once by passing multiple names separated by spaces:
rm symlink1 symlink2To get a confirmation prompt before removing the symlink, use the -i option:
rm -i symlink_nameType y and press Enter to confirm:
rm: remove symbolic link 'symlink_name'?Avoid the Trailing Slash
If the symbolic link points to a directory, do not append a trailing / to the symlink name. Otherwise, rm treats it as a directory and returns an error:
rm symlink_to_dir/rm: cannot remove 'symlink_to_dir/': Is a directoryThis happens because, when used without the -d or -r option, rm cannot remove directories.
Never use recursive removal when deleting symbolic links. If you run rm -rf on a symlink with a trailing slash, rm can follow the link and remove the contents of the target directory:
rm -rf symlink_to_dir/This can delete the actual files inside the target directory, not just the symlink. Always omit the trailing slash when removing symlinks.
Remove Symbolic Links with unlink
The unlink
command deletes a single file. Unlike rm, it accepts only one argument.
To delete a symbolic link with unlink, pass the symlink name as an argument:
unlink symlink_nameIf the command succeeds, it produces no output.
Do not append a trailing / to the symlink name because unlink cannot remove directories.
Find and Delete Broken Symbolic Links
If you delete or move the target file, the symbolic link becomes dangling (broken) and no longer works.
To find all broken symbolic links under a given directory, run the following command:
find /path/to/directory -xtype l/path/to/directory/symlink1
/path/to/directory/subdir/symlink2The -xtype l test matches symbolic links whose targets do not exist.
To limit the search to the current directory level without descending into subdirectories, pass the -maxdepth 1 option to find
:
find /path/to/directory -maxdepth 1 -xtype l/path/to/directory/symlink1Once you find the broken symlinks, you can remove them manually with rm or unlink, or use the -delete option of find to remove them all at once:
find /path/to/directory -xtype l -deleteTroubleshooting
rm: cannot remove ‘symlink/’: Is a directory
You appended a trailing / to a symlink that points to a directory. Drop the slash: rm symlink. Never use rm -rf symlink/ because it can follow the link and remove the target directory contents.
rm: cannot remove ‘symlink’: No such file or directory
The symlink does not exist at that path, or you are in the wrong directory. Verify with ls -l symlink and use an absolute path if needed.
unlink: cannot unlink ‘symlink’: Operation not permitted
You do not have write permission on the parent directory. Check ownership with ls -ld . and rerun with sudo only if the parent is system-owned.
FAQ
Does removing a symlink delete the original file?
No. Removing a symlink only deletes the link itself. The original file or directory it points to remains intact.
How do I check if a file is a symlink?
Run ls -l filename. If the first character of the permissions string is l, the file is a symbolic link. The output also shows the target after a -> arrow.
What happens to a symlink when the target is deleted?
The symlink becomes a dangling (broken) link. It still exists on disk, but any attempt to access it will fail with a “No such file or directory” error. Use find /path -xtype l to locate broken symlinks.
What is the difference between rm and unlink for removing symlinks?
Both commands remove symlinks the same way. The main difference is that unlink only accepts a single argument, while rm can remove multiple files at once and supports options like -i for interactive confirmation.
Conclusion
To remove a symbolic link, use rm or unlink followed by the symlink name. Do not append a trailing slash when removing a symlink that points to a directory.
Use find /path -xtype l when you need to clean up broken links after moving or deleting target files.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page