You've appended the word ``change'' to secondlink. Confirm this with cat
secondlink.
cat firstlink
firstlink also has the word ``change'' appended! That's because firstlink
and secondlink refer to the same file. It doesn't matter what you call it
when you change it.
chmod a+rwx firstlink
Changes permissions on firstlink. Enter the command ls -l to confirm that
permissions on secondlink were also changed. This means that permissions
information is stored in the inode, not in links.
rm firstlink
Deletes this link. This is a subtlety of rm. It really removes links, not
files. Now type ls -l and notice that secondlink is still there. Also
notice that the number of hard links for secondlink has been reduced to
one.
rm secondlink
Deletes the other link. When there are no more links to a file, Linux
deletes the file itself, that is, its inode.
All files work like this - even special types of files such as devices
(e.g. /dev/hda).
A directory is simply a list of filenames and inode numbers, that is, a
list of hard links.
Pages:
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192