Setup and Manage Symlinks on Ubuntu 18.04 | 16.04

This brief tutorial shows students and new users how to setup and manage symlinks when using Ubuntu Linux systems.

For those who don’t know, symlinks are files that links to other files. also known as soft links because they’re only links to the original files. If these links are deleted, the original files won’t be impacted since they’re only link references to them.

There’s also a hard link that functions more as copies of the files they reference than just literal links. In most instances, hard links are avoided since they’re copies of original files and may not be suitable since you’re duplicating the original files.

Symlinks are handy in many ways. Instead of restructuring the underlying filesystems to support applications and other services, developers can use symlinks without having to move files around or change file structure.

Symlinks only work if they’re pointing the files that already exist and spell out a clear path to a files they’re referencing. If the original files are deleted or moved, these symlinks will not function.

To setup symlinks in Ubuntu follow the steps below:

Creating Symlinks in Ubuntu

To create a symlink in Ubuntu, make sure symlink tool is installed. By default, it should be. If not, run the commands below:

sudo apt install symlinks

After installing symlinks tool, you can then run the commands below to create a symlink.

ln -s original-file.txt linkname

  • ln ==> command to create symlink
  • -s ==> command option which represents symlink
  • original-file.txt ==> the original file
  • linkname ==> the linkname that points to the original file

That’s how one creates a simple symlink to files.

Finding Symlinks

One can use the symlinks command to find symlink references in a given directory. However, the command may not come installed by default on Ubuntu.

Run the commands below to install symlinks.

sudo apt install symlinks

Now that symlinks is installed, use the commands below to search for symlinks.

If you want search for all symlinks in a particular directory, you run the commands below

symlinks -v directory

The commands above will display all symlinks in the specified directory.

If you want to search for all symlink in a particular directory recursively, you use the -r command option.

symlinks -vr directory

That should help you find symlinks in a specified directory.

That’s should do it!

Congratulations! You have learned how to create and search symlinks and references on Ubuntu

You may also like the post below:

Leave a Comment

Your email address will not be published.