Skip to main content

Understanding Symbolic Links in Linux

By May 22, 2013October 20th, 2016No Comments

In my earlier post, we defined inodes in the Linux file-system, this also took us into hard links. In this post we look at symbolic links, or symlinks as they are often abbreviated to.

Symbolics links are actual links and show as the file type link within the ls -l output and that of the command file. If directory colors are turned on then symlinks will show as light blue but with or without colors on you will see the first character in the out put of ls -l for the symlink name is “l”. This denotes a link. This is different to hard links which are regular files.

These are completely separate files in the file-system and so have their own name, inode and data. The data of the symlink points to the original or target file. With hard links they are inodes that have more than one file name linking to them. Symlinks are more flexible in that they can link across filesystems to different partitions and drives  and link to directories. To create symlinks use the command:

ln -s <target> <linkname>

such as:

ln -s /usr/share/doc ./doc

The example creates a link called doc in the current directory to the directory /usr/share/doc.