Symbolic Links

UNIX filesystems have a feature called symbolic links, which are files that point to another file, called the target. They're similar to shortcuts in Windows.

There are two kinds of symbolic links: hard links and soft links.

Hard links create a file which points to the same space on the hard drive as the file which is being linked to, rather than to that file itself.

/home/me/file      /home/you/file
    |                    |
 hard link           hard link
    |                   ,'
    V               _.-`
HARD DRIVE <....--``

A file won't be deleted until every hard link to it is deleted.

To create a hard link, you use the ln command with the source file, and the target hard linked file:

ln arrayDat.txt arrayHard.txt

ls

Notice that any changes you make to arrayDat.txt will be reflected in arrayHard.txt.

Soft links create a file which points to the original file or directory.

/home/me/file <---Soft link--- /home/you/file
     |
     |
     V
HARD DRIVE

Soft links break if the original file is deleted.

To create a soft link, you use the ln command with the -s flag.

ln -s arrayDat.txt arraySoft.txt

ls -l

Notice that any changes you make to arrayDat.txt will be reflected in arraySoft.txt. The ls command will show that arraySoft.txt points to the file arrayDat.txt.

Your Luria home folder has a couple of soft links automatically set up pointing to storage servers so that common programs don't take up too much space on the head node.

Last updated

Massachusetts Institute of Technology