Hard link and symbolic link, it’s confusing … no more

One Way Hard link or Symbolic link

Many times we want to manage we want to quickly find a file or directory that is outside our working directory, and we know that going there will take us longer than we have, the links are a good way to get out of this predicament.

Let’s start, hard links allow us to point to a file or files sharing the same inode, this means that this file will be an exact copy of the files to which it points, the permissions, owner and data will be the same. You must be careful because if you make changes to the files or the link, you will be affecting the original files. The way to create a hard link in linux is the following:

ln [OPTION]... [-T] TARGET LINK_NAME

For example:

Command ln, hard link

In this case we create a link to the file “login_github” and name it “_link_to_file”, if we list the files we can see that both the original file and the link created have the same owner, permission and data.


A symbolic link looks like the typical shortcut that we use in windows, this means that the file that contains the link is a pointer to a file or directory, which allows us to quickly access them. For this we use the -s option as indicated by the command hand.

-s, --symbolic
make symbolic links instead of hard links
Command ln, symbolic link

As we can see the file “_link_to_directory” points to a directory, which indicates that I can use that reference if I have to write the directory path, for example list the content:

The main differences that you must take into account to use hard links or symbolic links are the following:
- Hard links can only be created between files not with directories.
- Symbolic links can be created for files and directories.
- The hard links share the inode number, the symbolic ones do not (consult that it is inode here).
- The hard links are exact copies of the file, while the symbolics are just pointers.

That is all… Happy Coding!!