N
Common Ground News

Why we use hard link in Linux?

Author

Carter Sullivan

Updated on March 15, 2026

Why we use hard link in Linux?

On Unix filesystems .. is a real directory entry; it is a hard link pointing back to the previous directory. Hard links are the tendons that tie the filesystem's directories together. Once upon a time, Unix didn't have hard links. They were added to turn Unix's original flat file system into a hierarchical filesystem.

Keeping this in view, what is the use of hard link in Linux?

A hard link is a file that points to the same underlying inode, as another file. In case you delete one file, it removes one link to the underlying inode. Whereas a symbolic link (also known as soft link) is a link to another filename in the filesystem.

Additionally, how do hard links work? Hard link is the exact replica of the actual file it is pointing to . Both the hard link and the linked file shares the same inode . If the source file is deleted ,the hard link still works and you will be able to access the file until the number of hard links to file isn't 0(zero).

In this way, what is hard link and Softlink in Linux?

A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file. If you delete the original file, the soft link has no value, because it points to a non-existent file. But in the case of hard link, it is entirely opposite.

What are links in Linux?

In your Linux file system, a link is a connection between a file name and the actual data on the disk. There are two main types of links that can be created: "hard" links, and "soft" or symbolic links. A symbolic link is a special file that points to another file or directory, which is called the target.

4 Answers. You can delete it with rm as usual: rm NameOfFile . Note that with hard links there is no distinction between "the original file" and "the link to the file": you just have two names for the same file, and deleting just one of the names will not delete the other.
The reason hard-linking directories is not allowed is a little technical. Essentially, they break the file-system structure. You should generally not use hard links anyway. Symbolic links allow most of the same functionality without causing problems (e.g ln -s target link ).
2 Answers. When you create a hardlink, you are creating two separate file system entries pointing to the same physical data on the disk. This does not mean that the hardlinks take up this space - in fact they do not. A hard link takes up very little space.

What is Shell Linux?

The shell is the command interpretor in an operating system such as Unix or GNU/Linux, it is a program that executes other programs. It provides a computer user an interface to the Unix/GNU Linux system so that the user can run different commands or utilities/tools with some input data.
To create a symbolic link pass the -s option to the ln command followed by the target file and the name of link. In the following example a file is symlinked into the bin folder. In the following example a mounted external drive is symlinked into a home directory.
To create a hard links on a Linux or Unix-like system:
  1. Create hard link between sfile1file and link1file, run: ln sfile1file link1file.
  2. To make symbolic links instead of hard links, use: ln -s source link.
  3. To verify soft or hard links on Linux, run: ls -l source link.
You can learn a file's inode number and the number of links to it by running ' ls -li ' or ' find -ls '. You can search for hard links to inode number NUM by using ' -inum NUM '.
ls command to find a symbolic link in UNIX systems
If you combine the output of ls command with grep and use a regular expression to find all entries which start with small L than you can easily find all soft link on any directories. The ^ character is a special regular expression which means the start of the line.
The major difference between a hard link and soft link is that hard link is the direct reference to the file whereas soft link is the reference by name which means it points to a file by file name. Hard link links the files and directories in the same file system, but the Soft link can traverse file system boundaries.
A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file. If you delete the original file, the soft link has no value, because it points to a non-existent file. But in the case of hard link, it is entirely opposite.

How do I change permissions in Linux?

To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.

What does chmod do in Linux?

In Unix and Unix-like operating systems, chmod is the command and system call which is used to change the access permissions of file system objects (files and directories). It is also used to change special mode flags. The request is filtered by the umask. The name is an abbreviation of change mode.
When you delete ( rm ) a link the counter is decremented (reduced) by one. If the link counter reaches 0 the filesystem removes the inode and marks the space as available for use. In short, as long as you do not delete the last link the file will remain. Edit: The file will remain even if the last link is removed.
A hard link is actually nothing more than a regular directory entry, which in turn can be seen as a pointer to the actual file's data on the disk. This number is actually the link-count of the file, when referring to a file, or the number of contained directory entries, when referring to a directory (including the .
A soft link is similar to the file shortcut feature which is used in Windows Operating systems. Each soft linked file contains a separate Inode value that points to the original file. As similar to hard links, any changes to the data in either file is reflected in the other.
Symbolic links are used all the time to link libraries and make sure files are in consistent places without moving or copying the original. Links are often used to “store” multiple copies of the same file in different places but still reference to one file.
Deleting a target file for a symbolic link makes that link useless. A hard link preserves the contents of the file. A hard link cannot be created for directories, and they cannot cross filesystem boundaries or span across partitions.
For hard links, FAT filesystems lack a file node that can be 'shared' among files. There would also be no way to keep track of the number of links to a file.
To remove a symbolic link, use either the rm or unlink command followed by the name of the symlink as an argument. When removing a symbolic link that points to a directory do not append a trailing slash to the symlink name.
Each hard linked file is assigned the same Inode value as the original, therefore they reference the same physical file location. Hard links more flexible and remain linked even if the original or linked files are moved throughout the file system, although hard links are unable to cross different file systems.
To make links between files you need to use ln command. A symbolic link (also known as a soft link or symlink) consists of a special type of file that serves as a reference to another file or directory. Unix/Linux like operating systems often uses symbolic links.
Links has a lot of the features you'd expect in a graphical browser like Chrome or Firefox, as well. You can bookmark pages, search for text within a page, and even access your history. Links is really simple to use too. To use Links, simply type links <url> on the command line.

What is make in Linux?

make is typically used to build executable programs and libraries from source code. Generally speaking, make is applicable to any process that involves executing arbitrary commands to transform a source file to a target result.

What are Linux commands?

Linux Shell or “Terminal
So, basically, a shell is a program that receives commands from the user and gives it to the OS to process, and it shows the output. Linux's shell is its main part. Its distros come in GUI (graphical user interface), but basically, Linux has a CLI (command line interface).