How to create a hard links in Linux / UNIX
Q. Both Linux / UNIX allows the data of a file to have more than one name in separate places in the same file system. Such a file with more than one name for the same data is called a hard-linked file. How do I create a hard link in Linux / UNIX?
A. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file systems.
ln command to make links
ln command make links between files. By default, ln makes hard links.
ln command syntax
ln {source} {link}
Where,
=> source is an existing file
=> link is the file to create
To create hard link for foo file, enter:
ln foo bar
ls -i foo
ls -i bar
Hard links limitations
There are some issues with hard links that can sometimes make them unsuitable. First of all, because the link is identical to the thing it points to, it becomes difficult to give a command such as "list all the contents of this directory recursively but ignore any links". Most modern operating systems don't allow hard links on directories to prevent endless recursion. Another drawback of hard links is that they have to be located within the same file system, and most large systems today consist of multiple file systems.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Unix Create a Symbolic Link
- Why is it possible to create symbolic links across file system boundaries?
- How to: Linux / UNIX create soft link with ln command
- Linux / UNIX advantage of creating soft links instead of copy a file
- Linux / UNIX find files with symbolic links
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: command_syntax, directory_entry, hard_links, Linux, ln_command, source_link, UNIX



Recent Comments
Today ~ 3 Comments
Today ~ 57 Comments
Yesterday ~ 9 Comments
Yesterday ~ 7 Comments
Yesterday ~ 1 Comment