Skip to content
Follow
Ubuntu Linux

How to Remove Symbolic Links in Ubuntu Linux

Richard
Written by
Richard
Jan 24, 2024 Updated Jun 20, 2026 3 min read
Enable Automatic Suspension in Ubuntu Linux Easily
Enable Automatic Suspension in Ubuntu Linux Easily

You remove symbolic links in Ubuntu Linux using the rm command.

A symbolic link, often called a symlink, acts like a shortcut, pointing from its location to a different file or directory on your system.

For instance, a symlink created with ln -s /home/user/documents /home/user/docs in Ubuntu 22.04 LTs allows you to access your documents via the docs directory.

You’ll want to delete these symlinks to keep your file system tidy, especially when the original target file or directory has been moved or deleted.

When you remove a symlink, you’re only deleting the link file, not the original data it referenced, ensuring your important files remain safe.

⚡ Quick Answer

Use the `rm` command followed by the symbolic link’s name in the terminal. Alternatively, the `unlink` command can also remove a symbolic link. This action deletes only the link, not the original file or directory it points to.

Open the terminal

The terminal is your gateway to performing command-line tasks on Ubuntu Linux. To open it:

  • Press Ctrl+Alt+T on your keyboard. This keyboard shortcut launches the terminal window.

To remove a symbolic link in Ubuntu, you first need to go to the folder where it’s stored using the ‘cd’ command.

Now, you need to change into the directory where your symbolic link is located. You’ll use the cd command for this. For example, if your symlink is in your Downloads folder, you’d type: `cd ~/Downloads`.

Command Prompt
cd ~/Downloads

Remember to replace ~/Downloads with the actual path to the directory containing your symbolic link.

Before you remove a symbolic link in Ubuntu, it’s smart to check it’s there and see what it points to using the ‘ls -l’ command.

🐧Bash / Shell
ls -l

Look for entries that start with lrwx, indicating they are symbolic links.

🐧Bash / Shell
ls -l /usr/bin/python

The output will also show where the link points to.

💻Code
lrwxrwxrwx 1 root root 12 Apr 16  2023 /usr/bin/python -> python2.7

You can remove a symbolic link in Ubuntu by using the ‘rm’ command followed by the link’s name.

💻Code
rm symlink_name

Replace symlink_name with the actual name of your symbolic link. This command removes the symlink itself, not the target file or directory.

💡Tip
To get prompted before removing the symlink, use the -i option:
💻Code
rm -i symlink_name

Another way to remove a symbolic link in Ubuntu is by using the ‘unlink’ command.

The unlink command is a bit more focused; it can only handle one symlink at a time.

To delete a symbolic link, run the unlink command followed by the symlink name as an argument:

💻Code
unlink symlink_name

That should do it!

Conclusion:

  • Removing symbolic links in Ubuntu Linux is essential for maintaining a clean and efficient file system.
  • Properly managing symbolic links helps reduce clutter, improve system performance, and avoid confusion when accessing files and directories.
  • The rm command or the unlink command can remove symbolic links based on your specific requirements.
  • Always exercise caution when removing symbolic links to ensure you do not inadvertently delete essential files or directories.
  • Feel free to share your feedback or tips in the comments section below.

To remove all symbolic links in Ubuntu, you can use either the ‘unlink’ or ‘rm’ commands, but ‘unlink’ is safer as it can’t delete directories.

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.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Delete Files and Folders in Windows 11
Windows How to Delete Files and Folders in Windows 11
How to Unlink OneDrive Windows 11: A Complete Guide
Windows How to Unlink OneDrive Windows 11: A Complete Guide

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *