A hard link is file system entry that associates a name with another file on a file system.

learn more… | top users | synonyms (1)

28
votes
5answers
5k views

Why do hard links exist?

I know what hard links are, but why would I use them? What is the utility of a hard link?
64
votes
5answers
17k views

Why hard links not allowed to directories in UNIX/Linux

I read in text books that UNIX/Linux doesn't allows hard links to directories but soft links do. Is it because, when we have cycles and if we create hardlinks, and after some time we delete the ...
29
votes
7answers
11k views

What is the difference between symbolic and hard links?

When would you use one over the other?
34
votes
2answers
1k views

Why is '.' a hard link in Unix?

I've seen many explanations for why the link count for an empty directory in Unix based OSes is 2 instead of 1. They all say that it's because of the '.' directory, which every directory has pointing ...
12
votes
1answer
956 views

How to find all the links to a directory

When I stat a directory I get a listing that tell me there are 5 links to the directory. stat dir My question is how do I get information (names and locations) to all these 5 links?
7
votes
2answers
3k views

How to `du` only the space used up by files that are not hardlinked elsewhere?

Using rsync --link-dest for space-saving snapshots, how can I figure out how much space I actually saved? Or more general: How to figure out how much space a directory uses considering only files ...
7
votes
5answers
7k views

How to copy directories with preserving hardlinks?

How to move directories that have files in common from one to another partition ? Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks. How to move such ...
8
votes
5answers
4k views

Can I determine the number of sub-directories in a directory using `ls -l`?

When displaying directories using ls -l, their number of links (the second field in the output) is at least two: one for the dir name and one for . $ mkdir foo $ ls -l total 2 drwxr-xr-x 2 user ...
4
votes
4answers
442 views

Symbolic link and hard link questions

Let's say /A/B/c.sh is symbolic linked to /X/Y/c.sh. If c.sh has the command "./SOMETHING", '.' means /A/B/ or /X/Y/? How about the hard link?
1
vote
2answers
951 views

Keep tracking of symbolic links?

I use symbolic links quite often, but after moving the original file, I lose track of the symbolic link. I also use symbolic links for keeping track of some files in the same directory, but again, I ...