Datasheet

18
Phase 1
Working on the Command Line
Setup
You need perform no special setup to perform this task; just log into your computer as the user
who owns the files in the /home/project7 directory and type cd /home/project7 to change
into that directory. Be sure to complete Task 1.2 before starting this task.
Caveats
If you perform this task as an ordinary user, the risk to the computer is minimal. If you opt
to perform this task as root, though, you might accidentally delete or corrupt important sys-
tem files, particularly if you perform these steps in the wrong directory.
Procedure
The ln command creates links, so it’s the most important command to know when it comes
to link management. Other link-related tasks can be performed using ordinary Linux file-
manipulation commands, such as mv, cp, and rm.
Links require support in the underlying filesystem. Although all Linux native
filesystems support links, they aren’t supported in some non-Linux filesys-
tems, such as the File Allocation Table (FAT) filesystem used by DOS and
Windows. Thus, if you use non-Linux filesystems on removable disks or par-
titions shared across OSs, you may not be able to create links on them.
Creating Hard Links
The ln command works much like the cp command; type the command name, the name of the
current file, and the link filename you wish to use:
$ ln sample-file fstab
This command creates a hard link between the original sample-file and the new fstab.
(In Task 1.2, fstab was renamed sample-file.) A hard link is a duplicate filename that refers
to the original file. Both filenames are equally valid, and once a hard link is created, either may
be used with precisely the same effect. You can tell how many hard links exist by examining
the long output of ls:
$ ls -l
total 9
drwxr-xr-x 22 fred users 1184 May 25 12:51 X11
-rw-r--r-- 2 fred users 2260 May 25 12:51 fstab
-rw-r--r-- 2 fred users 2260 May 25 12:51 sample-file
The second column of this output shows, for ordinary files, the number of filenames that
point to the file. Ordinary files show 1 in this column; files with a single hard link in addition to
83484.book Page 18 Monday, September 18, 2006 8:58 AM