Files & Filesystems / Create Hard & Symbolic Links
Subtitles of the Movie
Exam objective 1.104.7 has a weight of 1, and verifies that candidates are able to create and manage hard and symbolic links to a file. You need to be able to create links, identify links, and understand the difference between copying files and linking them. A file doesn't have a name. A file is a location on disk, and that location is given a name by having a listing in a directory. Look at this. This command creates a file containing some text. It also adds an entry into the current directory that contains its address. Its address is known as an Inode and you can see the Inode number of a file with the I option on LS. Here you can see that the name in the directory is Walnut, and the file is located at Inode 8181. The LN command can be used to add another directory entry for the same file. The LN command creates a new directory entry, Pecan, that points to the same Inode. You can see that the two names point to the same Inode. The same file has two names. These names are called Hard Links. Accessing the file through either name will access the same file. If you change it under one name, it will change under the other. Look at this. Notice this number. This is a count of the number of hard links to the file. You can delete either of these links and the file will remain. To get rid of the file, you need to delete both links and then the system will notice that the Inode is an orphan and it will be put back in the free space. You can have as many hard links to a file as you want. The links are all equal. There's no primary or secondary link. The links can be in different directories. The only requirement is that the directory be on the same disk partition as the file. You can make hard links to directories just as well as files. Actually a directory is just another file. It contains a list of names with Inode locations. When a directory is first created, it already contains two links. The name Dot is linked to itself, and the name Dot Dot is a link to the parent directory. The S option on the Link command creates a different kind of link; a symbolic link. It is a link, but it's a bit different. Look at the Inode. You can see that for this new link the Inode is a different number. That's because a symbolic link points to the same file but in a different way. The long form of LS shows that a symbolic link is a link to the directory entry, not to the file. Notice the dual names on the right, which shows that this is a symbolic link. The file permissions are not used on symbolic links. They all show up as if all permissions were granted, but the permissions on the Hard Link are the ones that apply. The first letter of the permissions is an L, which identifies it as a symbolic link. A symbolic link has the advantage that the directory and the file can be on separate partitions, even on separate disks. Adding symbolic links does not add to the link counter. A symbolic link can address a file that no longer exists. If you haven't already, you will someday see a broken link error message. You need to understand how links works because Linux is full of them, and they are handy if you know how to use them. Another way to delete a file is to use the Unlink command. Also, the command called Link can be used to make Hard Links. Look up these two commands in the MAN pages. A Linux installation is full of symbolic links. Notice how they're used to give simple names to different versions of executables and libraries.
Tutorial Information
| Course: | Linux Professional Institute: Level 2 |
| Author: | Arthur Griffith |
| SKU: | 33894 |
| ISBN: | 1-934743-79-8 |
| Release Date: | 2008-07-21 |
| Duration: | 7.5 hrs / 113 lessons |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 