A symbolic link (also symlink or soft link) is a term for any link that that point to a file or a directory in other locations on your system. You can think of them like advanced aliases in mac or shortcuts in windows.
The “link” can be one of two types:
– Hard link : this can only be applied to single files. Whatever you do to one file is replicated to the other file. For example ln [original_file] [shortcut_file]
– Soft link : this can also be applied to directories. When accessing the source file, you are redirected to the destination file. For example ln -s [original_file] [shortcut file]. Notice the addition of the -s switch to indicate a soft link
A symbolic or soft link points to a path in the file system. For example, let’s say you have a symbolic (or “soft”) link from /home/examplefile pointing to /var/examplefile. If you move the file at /var/examplefile, the link at /home/examplefile will be broken. However, if you create a “hard link”, it will actually point to the underlying inode on the file system. So, if you created a hard link from /home/examplefile pointing to /var/examplefile and later moved /var/examplefile, the link at /home/examplefile would still point to the file, no matter where you moved it to. The hard link works at a lower level.
You should generally use standard symbolic links, also known as “soft links”, if you’re not sure which to use.
How to Create Symbolic Links with ln
To create a symbolic link with the ln command, you’ll first need to open a terminal window. Once you have, run the ln command in the following form:
ln -s /path/to/original /path/to/link
You can specify either a path to a directory or file in the command. It will “just work”, whatever you enter.
So, if you wanted to create a symbolic link of your Downloads folder located on your Desktop, you’d run the following command:
ln -s /home/name/Downloads /home/name/Desktop
-s in the command creates a symbolic link. If you wanted to create a hard link instead—again, this is something you usually wouldn’t want to do unless you have a specific reason to do so—you’d exclude the
-s from the command.
In order to see the symlinks and what folder points to what, you can use the “ls -la” command.