There are two types of links in UNIX: symbolic and hard. This can make it easier to work with files as we are creating new names for them and shortcuts to certain files. A hard link means that we're giving another name to the file. The two names have the same value. In this case, if we delete one of them, the file remains, regardless of which one was created first.
We can delete a file/directory only after we have deleted all of its hard links. When we create a link, we just give another name to the file. If we delete either of its names, the other will be still valid. You can create this type of link only within the same partition.
Symbolic links, on the other hand, are just pointers to the file. If we delete the original file, the link will remain and point nowhere. We can create any number of links. There are no restrictions. Symbolic links can point across partitions. We use the ln command to create links.
The syntax of the command looks as follows:
ln [what file/directory] [what new name/link]
By default, the links are hard. If we want to create a symbolic link we need to add the -s option. For example, in the following lines, I will create a symbolic and a hard link to the alfa file.
ln alfa beta
ln -s alfa omega
Notice in the example below that the two hard links have the same i-node numbers, meaning they are exactly the same file under different names. The ls command also echoes back symbolic links, as you can see. These will display in a different color when they are invalid. Also, observe the same i-node numbers for alfa and beta in the image below: