Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain.

Similar presentations


Presentation on theme: "Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain."— Presentation transcript:

1 Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain a single copy on the disk. The file is then said to have more than one link or name, but all have the same inode number. This is called hard link. All attributes are identical any modification or change in one file is automatically available in the linked file. It provides some protection against accidental deletion. Let there be a file named restore.sh. You need to create another file which provides as backup to the original file. By creating a link, you create a backup. unix command used to create hard link >>ln- backup.sh restore.sh

2 Soft Link It doesn't have the file's content but simply provids pathname of that automatically has the contents. This is called as softlink. but incase the original file is deleted we can't get the file's content from the linked file, coz, it just provides the path name of the file. This is also known as symbolic link. Windows shortcuts are more like symbolic links. The original file and the linked files have different inode nos. Unix command used to create soft link>>ln-s

3 ln [existing_file] [linked_file]
Hard Link: ln [existing_file] [linked_file] A directory entry containing the same “i-node number” of a file. All files have at least one hard-link - when removed, the link is removed Symbolic Link: ln -s [existing_file] [linked_file] A directory entry containing pathname to file (i.e. a pointer). Unlike hard links, i-node numbers can be different, but possess other useful features.

4 Hard Link Vs Symbolic Link
A Hard link is a UNIX path name for a file ln /usr/mary/abc /usr/mary/xyz Symbolic links are created with the –s option ln –s /usr/mary/abc /usr/mary/xyz Limitations of hardlinks: Cannot create hardlinks for directories unless they have superuser privileges Users cannot create hardlinks on a file system that references files on a different system.

5 Hard Link Vs Symbolic Link
Does not create a new inode Create a new inode Cannot link directories, unless this is done by the root Can link directories Cannot link files across file systems Can link files across file systems Increase the hard link count of the linked inode Does not change the hard link count of the linked inode

6 ln Vs cp ln /usr/mary/abc /usr/mary/xyz
ln creates a new directory entry to a referenced file whereas cp creates a duplicated copy of the file to another file with a different name. ln /usr/mary/abc /usr/mary/xyz Inode number Filename 115 89 201 abc 346 a.out Inode number Filename 515 989 201 Xyz 146 Fun.c (ln –s)/ cp /usr/mary/abc /usr/mary/xyz Inode number Filename 115 89 201 abc 346 a.out Inode number Filename 515 989 345 Xyz 146 Fun.c


Download ppt "Hard Link when a file is copied, both the original and copy occupy separate space on the disk. unix allows a file to have more than one name and yet maintain."

Similar presentations


Ads by Google