The Definition of Symlink in Unix

Create virtual pointers in Linux

Linux symbolic links

On UNIX-based operating systems, a symbolic link or a symlink is a file in one directory that acts as a pointer to a file in another directory. For example, you could create a link so that all accesses to the file /tmp/foo really act upon the file /etc/passwd.

Creating Symlinks

Linux offers the ln command to create links, with the -s flag specifying a symbolic link. For example:

ln -s ~/todo.md /tmp/todo

will create a symbolic link in the /tmp directory to a todo.md file located in the user's home directory.

You can also create symbolic links of entire directories. This can be very useful for conserving space on a smaller drive by keeping larger directories on another one. A great example of this would be a games directory or the Steam folder. Games can take a ton of space, and if you're using a smaller SSD for your operating system, you probably don't want them eating up your limited rive space. You can link a games directory to a much larger drive on your system while making it seem like everything is still in your home directory.

ln -s /media/Storage/Games ~/Games

Something like that will ensure that you'll always have enough room for you library. This will work for Videos, Music, or really anything else.

Symlink Security

Athough a non-root user lacks permission to write to administrative files like /etc/passwd, an ordinary user account can create links to them in the /tmp directory or the home directory. SUID — a process where the operating system sets a specific user ID as the executing user when a file is accessed or a command executed — can then be exploited. This is the leading way that local users can escalate their privileges on a system.