FileSytems and Inodes
Every file is associated with table that contains all that you could possibly need to know about a file -- except its name and contents. This table is called the inode (index node)
and is accessed by inode number.
1) file type (regular, directory,device,etc)
2) file permissions
3)number of links
4) UID ownner
5)GID group owner
6)file size in bytes
7) Date and Time of last mmodification
8)date and time of Last access
9)date and time of last changes of the inode mnumber
10)array of pointers that keep tract of all disk blocks used by the file
Q. What are links in Unix?
Creating links is a kind of shortcuts to access a file. The two different types of links in UNIX are:
Soft Links or Symbolic Links
Hard Links
What is symbolic link or symlink?
Symbolic link, often called symlink or softlink, is very similar to what we know from Windows - a shortcut. They are kind of shortcuts in the Linux/Unix world. Well, symbolic link can exist in the Windows world too, but for the simplicity of our explanation, let's just work with the comparison that symlink is kind of a shortcut for now. We will get into more details later. Symbolic link contains information about the destination of the target file.
What is hard link?
Hard link (often also called hardlink) is a bit different object when compared to a symlink. Hard link is a directory reference or pointer to a file. Hardlink is a label stored in a directory structure that refers the operating system to the file data when it is accessed. The important part is that hard link is closely tied together with its originating file. If you make changes to a hard link, you automatically make changes to the underlying file that the hardlink is attached to.
Hard link can only refer to data that exists on the same file system.
Many of us are used to Windows where files live in folders. Files in Linux/Unix are not stored in directories. Files in Linux are assigned an inode number which Linux uses to locate files. Each file can have multiple hard links which are located in various directories. A file does not get deleted until there are no remaining hard links to it.
Differences between symbolic link and hard link
Let's summarize our findings. The list bellow summarizes some differences between symlink and hard link:
Hardlink or hardlinks cannot be created for directories (folders). Hard link can only be created for a file.
Symbolic links or symlinks can link to a directory (folder).
Removing the original file that your hard link points to does not remove the hardlink itself; the hardlink still provides the content of the underlying file.
If you remove the hard link or the symlink itself, the original file will stay intact.
Removing the original file does not remove the attached symbolic link or symlink, but without the original file, the symlink is useless (the same
Hard link limitations
1) You cant have two linked filenames in two filesystems. In other words, you can'tlink a filenamme in the /usr file system to another in the /home file system.
2) you can't link a directory even within same file system.
soft links
ln -s emp.list employees
Hard Links
ln emp.list employees employess doesnt exist
No comments:
Post a Comment