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.
- Email FAQ to a friend
- Printable version
- Rss Feed
- Last Updated: 10-9-07

{ 0 comments… add one now }