PROGRAMS

## Overview

There are two types of links in Linux:

hard links: Refer to a specific location. A hard link must be created to a file or directory that already exists. A hard link is commonly used in software build processes instead of copying to speed things up (as long as the files are not written too!). Modifying or moving the original file will not upset a hardlink.

For example, we will create a new “imaginary” file called ~/new_link.txt, which actually points to ~/a_folder/file_that_already_exists.txt.

ln -s ~/a_folder/file_that_already_exists.txt ~/new_link.txt


You can inspect symbolic links by running ls -l. If any of the files are a symbolic link, it will show the path that they link to.

For example, we will create a new “imaginary” file called ~/new_link.txt, which actually points to ~/a_folder/file_that_already_exists.txt.

\$ ln ~/a_folder/file_that_already_exists.txt ~/new_link.txt


This could be considered a bad first example, since it has quite similar behaviour to the soft link example above. Note that a hard link is the default link that ln will produce when given no options. It is not recommended to create a hard link to a directory (although it can be done on some POSIX systems).