Follow
Ubuntu Linux

How to Remove Symbolic Links in Ubuntu Linux

Richard
Written by
Richard
Jan 24, 2024 Updated Mar 19, 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.

Before you can remove a symbolic link, you need to locate it. You’ll also need write permissions for the directory holding the symlink.

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 it, it’s a good idea to confirm the symlink is there and see what it points to. Use the ls -l command for a detailed list.

🐧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

To remove it, type the rm command followed by the name of the symbolic link. Just type the symlink’s name. Don’t add any extra slashes or directory paths unless the link itself was created that way.

💻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.

To get prompted before removing the symlink, use the -i option:

💻Code
rm -i symlink_name

You can also remove symbolic links using the unlink command. The unlink command deletes a given file.

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.

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 *