Linux/Unix systems allow you to create links or additional names in different directories of a file system. Hard links are the old Unix way of creating links, with symbolic links (or symlinks) being the more modern approach. Symlinks, unlike hard links, have the ability to reference directories and to store multiple files in separate places that refer to a singular file. Imagine a Windows shortcut; symbolic links function almost exactly the same way.
Creating a Symbolic Link
To create a symbolic link we use the ln command again, only this time we add the -s option to specify a Symbolic link. The command syntax is simple and the same as creating a hard link.
ln -s [target file] [symbolic link name]
Creating Symbolic Links for Directories
The command to create a symlink to a directory is as follows:
ln -s [folder/directory] [symlink name]
Let's link a folder to a simplified destination using symbolic links.
We can see that the contents of /sys/devices/software/power/ are not displayed within the symbolic link /powerfolder.
There are a few options that we are given by Symbolic Links. Take the time to check out how they work.
Deleting a Symbolic Link
The rm or unlink commands will delete a symbolic link, and they both function the same way.
rm [symlink name]
unlink [symlink name]
Please sign in to leave a comment.