How to create symbolic links in Linux

Learning symbolics is a great way to increase your potential in the Linux terminal. In this tutorial, we will cover some commands to learn how to create a symbolic link in a quick and easy way. But before we start, let’s see what symbolic links are.

What are Linux symbolic links

Symbolic links are not only useful for creating shortcuts and managing files on operating systems like Linux. They also serve as a way to create multiple locations for your main user folders, eg Documents, Pictures, Downloads, and more!

Symbolic links act like a chain that creates paths for different files, folders, and directories on the computer system. They are able to create and store multiple files in different places, they refer to a single file. Thus, increasing efficiency by locating all specific documents in one command.

These links are stored on the mainframe, so even if the original file is deleted, you will still have a backup of most important files. Symbolic links help create invalid link paths to store pieces of information as per user requirements.

Due to the user-friendly features in Linux, even Microsoft is following suit to create symbolic links. Symbolic Links, also known as Soft Links or Symlinks, are not unique to Linux, but are like a search option in Windows where you can search for a specific file or directory on a drive by running various commands.

How to create symbolic links in Linux?

Let’s see how you can create file and folder links in Linux:

Create symbolic link in Linux for files

In general, to create links we use the command ln and the option -s to specify symbolic links. This is the easiest way to ensure a flexible approach that allows you to experiment with the language as much as possible. There is nothing difficult about creating symbolic links in Linux: you just need to follow a simple step.

See also  Coupon | Promotional Codes 2022 - Get 78% Discount OFF

ln -s

The ln command in Linux creates links between source files and directories.

  • -s: the command for symbolic links.
  • : name of the existing file for which you are creating the link
  • : symbolic link name.

The created links can be verified by directory listing using the verbose list command:

ls -l

However, if you don’t specify the , the command will automatically create a new link in the existing directory.

Create symbolic link in Linux for folders

Creating symbolic links for folders is also not difficult. The command used to create the folder symbolic link is:

ln -s

For example, to link the directory /user/local/downloads/logo to the folder /devisersuse the following command:

ln -s /user/local/downloads/logo /devisers

Once a symbolic link is created and attached to the folder /deviserswill take you to /user/local/downloads/logo. When the user changes the directory – cd a /devisersthe system will automatically switch to the specific file and write it to the command directory.

Symbolic link options are called command line switches. Here are the most common ones and their descriptions:

command switchDescription-backup backup each existing target file -d, -F, –directory superuser can attempt a hard link -f, –force delete existing target file -I, –interactive ask before deleting target files -L, — logicaldeference targets that are n-symlinks, –non-dereferencesymlinks to the directory are treated as P-files, –physicalconverts hard links directly to r-symlinks, –relativecreates symlinks relative to the s-link location, – symbol make symbolic links instead of hard links -S, –suffix=SUFFIXoverrides the usual backup suffix -v, –verbose prints the name of each linked file

See also  How to configure a Firewall in Ubuntu 18.04 with UFW

How to change or remove a symbolic link in Linux?

You can remove existing links attached to files or directories using the unlink or rm command. This is how you can do it with the unlink command:

unlink

Removing the symbolic link using the rm command is similar to the unlink command as seen below:

rm

For example:

rm simpleText

In conclusion

Remember that if the font is no longer in the current location, you should delete the symbolic files to avoid creating duplicates, which could slow down your work.

it is a wonderful platform to create an interactive and dynamic application, where you can experiment and innovate. A solid foundation is critical. Thoroughly learn the basic language to use it to its full potential. We hope this tutorial helped you improve your skills with another useful tool!

Gustavo is passionate about creating websites. He focuses on the application of SEO strategies at for Spain and Latin America, as well as the creation of high-level content. When he is not applying new WordPress tricks you can find him playing the guitar, traveling or taking an online course.

Loading Facebook Comments ...
Loading Disqus Comments ...