1.8 KiB
1.8 KiB
LPIC-1 104.6: Hard and symbolic links
Hard links and symlinks side by side, the limits of hard links, directory
link counts, switching a current symlink, and following a chain of
links.
Before you start
The lab creates an empty /root/links/. Work as root (sudo -i) and in
that directory, and write answers to the files in /root/lab-answers/.
Tasks
- Create
original.txtwith some text, make a hard linkhard.txtand a symlinksoft.txtto it, and look at all three withls -li. Delete the original, thencatboth links. - Try to hard-link a file onto another filesystem (
dfshows which directories are on separate ones;/dev/shmis a tmpfs everywhere, while/tmpis only on some systems), and to hard-link a directory. Write both error messages to/root/lab-answers/2. - Make a directory
parent, check its link count, add two subdirectories, and check again. Write the first count on line 1 of/root/lab-answers/3and the second on line 2. - Set up
releases/1.0,releases/1.1and acurrentsymlink inreleases/pointing to1.0. Switchcurrentto1.1withln -sf, and then withln -sfn, and look at what each did. - On Debian or Ubuntu, follow
/usr/bin/editorto the real program withreadlink -f, and withls -lone link at a time. Write every name in the chain, from/usr/bin/editorto the real program, one per line, to/root/lab-answers/5.
Hints
ln,ln -s,ls -li; a symlink stores a name, a hard link is another name for the same inode.ln FILE /dev/shm/;ln DIR NEWNAME.ls -ld parent(the second column),stat -c %h parent.- Without
-n,ln -sf 1.1 currentfollowscurrentinto1.0and makes the link there. readlink -f,ls -l /usr/bin/editor, thenls -lon what it points to.