Java Reference
In-Depth Information
drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 10:13 .
drwx------ 50 mschwarz mschwarz 4096 Jul 8 10:11 ..
-rw-rw---- 2 mschwarz mschwarz 45 Jul 8 10:11 example
-rw-rw---- 2 mschwarz mschwarz 45 Jul 8 10:11 sample
$
As you can see, a file can have only one set of owners and permissions, no
matter how many links are made to it. Changing the owner or permissions of
one link changes all hard links at the same time. In other words, the security
of a file is like its data: A change to one link is a change to them all.
A link need not be in the same directory as the original name.
$ ln example /tmp/sample
$ ls -la
total 16
drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 10:13 .
drwx------ 50 mschwarz mschwarz 4096 Jul 8 10:11 ..
-rw-rw---- 3 mschwarz mschwarz 45 Jul 8 10:11 example
-rw-rw---- 3 mschwarz mschwarz 45 Jul 8 10:11 sample
$ ls -la /tmp
total 132
drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 10:23 .
drwx------ 50 mschwarz mschwarz 4096 Jul 8 10:11 ..
-rw-rw-r-- 1 mschwarz mschwarz 118081 Jun 3 18:51 jLin.tar.gz
-rw-rw---- 3 mschwarz mschwarz 45 Jul 8 10:11 sample
$
Here we made a third link in a different directory; /tmp/sample is a third
name for the same data file. Note that we made it from the example link, not
the original filename. In fact, as far as the Linux filesystem is concerned, there
is no “original” name. None of these names is more significant than any other.
When you remove a filename, the link is destroyed and the file's link count is
decremented. If the link count goes to zero, the file is removed. That's it.
Nothing else.
Hard links have a couple of drawbacks. One of them is a genuine technical
limitation and the other is more of a usability problem. The technical limitation
is that a hard link cannot be made across mounted filesystems. In the simplest
Search WWH ::




Custom Search