Skip to content
Follow
Ubuntu Linux

How to Remove Symbolic Links in Ubuntu Linux

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

Symbolic links in Ubuntu Linux act as shortcuts that point to files or folders in other directories. Removing a symbolic link deletes only the pointer itself while leaving your original files completely untouched.

Advertisement

You can clear out these broken or unwanted shortcuts in Ubuntu 22.04 and other recent versions using the basic terminal command rm or unlink. This keeps your file system clean without risking any of your actual data.

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

Advertisement

Open the terminal

Press Ctrl+Alt+T to open the terminal.

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

To remove symbolic links Ubuntu users first need to open the folder where the shortcut lives. You do this by typing cd followed by the folder path in your terminal window. This moves your command line session into the correct folder so you can find and delete the link safely without touching other files.

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

cd ~/Downloads

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

Advertisement

To remove symbolic links Ubuntu users must check the exact name of the shortcut before deleting it. Type ls -l in your terminal to see a detailed list of files in the current folder. Look for lines that start with the letter l and point to your original file, which confirms you have the right link.

ls -l

Look for entries starting with lrwx, indicating they function as symbolic links.

ls -l /usr/bin/python

The output also displays where the link points.

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

To remove symbolic links Ubuntu provides the rm command, which deletes the shortcut without touching your original files. Type rm followed by the name of your link and press Enter. This permanently deletes the shortcut from your system while keeping the target file or folder safe and intact.

Advertisement
rm symlink_name

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

Appending the -i option triggers a prompt before removing the symlink:

rm -i symlink_name

To remove symbolic links Ubuntu offers an alternative tool called the unlink command that deletes one shortcut at a time. Type unlink followed by the name of your link and press Enter. This method is built specifically for shortcuts and removes the link safely without affecting your original data.

The unlink command focuses on handling one symlink at a time.

Advertisement

Run the unlink command followed by the symlink name as an argument to delete a symbolic link:

unlink symlink_name

That completes the process.

Removing symbolic links helps reduce clutter and avoid confusion when accessing files and directories. Use either the rm or unlink command depending on your setup.

  • 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, developers use either the 'unlink' or 'rm' commands, preferring 'unlink' because it cannot delete directories.

Removing a symbolic link requires rm or unlink followed by the symlink name. Omitting trailing slashes prevents errors when removing a symlink pointing to a directory. Running find /path -xtype l cleans 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.

Advertisement

📚 Related Tutorials

How to Install RabbitMQ on Ubuntu Linux
Ubuntu Linux How to Install RabbitMQ on Ubuntu Linux
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 *