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
, and if you are unsure which link type to use, see hard links vs symbolic links
.
This guide explains how to remove symbolic links in Linux using the rm, unlink, and find commands.
Quick Reference
For a printable quick reference, see the ln cheatsheet .
| 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 |
| Find broken symlinks (portable) | find -L /path -type l |
| Delete broken symlinks | find /path -xtype l -delete |
| Remove every symlink in a tree | find /path -type l -delete |
Before You Begin
To remove a symlink, you need write and execute (search) permission on the directory containing it. You also need search permission on the directories leading to it.
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 Mar 21 2026 /usr/bin/python3 -> python3.14The 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.
With GNU rm, a trailing slash makes the path resolve to the target directory. A recursive command such as rm -rf symlink_to_dir/ can then delete the directory’s contents. The directory itself remains, and the symlink still points to it. Without -f, rm -r symlink_to_dir/ can delete the same contents before reporting Not a directory.
To remove only the link, run rm symlink_to_dir without a trailing slash.
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. If you do, unlink refuses to remove the link:
unlink symlink_to_dir/unlink: cannot unlink 'symlink_to_dir/': Not a directoryThe link is still in place. Drop the slash and run unlink symlink_to_dir again.
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 broken symbolic links, including links whose targets are missing.
The -xtype test belongs to GNU find, which is what Ubuntu, Debian, Fedora, and RHEL ship. On systems with BSD find, such as macOS, use the -L option instead. It tells find to follow symbolic links, so a working link is reported as whatever it points at, and only the broken ones are still left matching -type l:
find -L /path/to/directory -type lThis form works with both BSD and GNU find. The -L option can take the search outside the starting tree by following links to directories. To skip linked directories with GNU find, use -xtype l without -L.
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 -deleteRemove All Symbolic Links in a Directory
Sometimes you need to clear every symlink under a directory, not only the broken ones. Drop the x from the test so that find matches links whether or not their targets still exist, and list them before removing anything:
find /path/to/directory -type l/path/to/directory/symlink1
/path/to/directory/config_link
/path/to/directory/subdir/symlink2Once the list matches what you expect, add -delete to the same command:
find /path/to/directory -type l -deleteThe files and directories those links pointed to are left alone. -delete removes the directory entry for each link without following it, so only the links disappear.
Troubleshooting
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/’: Not a directory
This can happen when you add a trailing / to a symlink that points to a regular file. If you ran rm -r on a link to a directory, check the target directory before removing the link. If the command removed files you need, restore them from a backup.
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’: Permission denied
Check for write and execute permission on the parent directory and execute permission on the directories leading to it. Use ls -ld . to inspect the parent if the link is in your current directory. If the directory has the sticky bit set, check who owns the link with ls -l symlink.
rm: cannot remove ‘symlink’: Operation not permitted
The link may belong to another user in a directory with the sticky bit set, such as /tmp. In that case, only the link owner, the directory owner, or root can remove it. The default unlink on Ubuntu 26.04 prints Permission denied for the same case.
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 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page