Hardlink
Hardlink is possible within the same filesystem
Hardlink pointing to the same inode
Hardlink cannot create a link for a directory
Hardlink does not break even if you change the name of the original file
Softlink (symlink)
Softlink is possible in a different filesystem
Softlink have different inode
Softlink can be used to create a link for both directory & file
Softlink will break if you change the name of the original file because it resolves the name of the file each time you access it through the softlink.
Inode(Index Node):-
Inode is a data structure (or) it is a file structure on a file system, Each inode stores the attributes of the file system objects.Inode contains the following information about the file:-
- Inode Number
- File Permission
- File Change (or) Modify Time
- Owner (user-id of the file) & (group-id of the file)
- Size of the File
- Device ID (this identifies the device containing the file).
- Disk Block Location
- Number of links
- Status flags
To create Softlink in linux:-
Use the following syntax:-
# ln -s <source-file> <link-file>
[root@lenovo ~]# ln -s /var/ftp/pub/file1.txt /softlink/file1.txt
[root@lenovo ~]# ll -ltrh /softlink/
lrwxrwxrwx. 1 root root 22 Jun 8 10:26 file1.txt -> /var/ftp/pub/file1.txt
To unlink the file in linux:-
Use the following syntax:-
# unlink <linkname>
[root@lenovo ~]# unlink /softlink/file1.txt
To create Hardlink in linux:-
Use the following syntax:-
#ln <source-file> <link-file>
[root@lenovo ~]# ln /var/ftp/pub/file2.txt /linkdir/file2.txt
[root@lenovo ~]# ls -li /var/ftp/pub/file2.txt
1181563 -rw-r--r--. 2 root root 0 Jun 8 10:50 /var/ftp/pub/file2.txt
[root@lenovo ~]# ls -li /linkdir/file2.txt
1181563 -rw-r--r--. 2 root root 0 Jun 8 10:50 /linkdir/file2.txt
[Note:- see after creating hardlink both the files showing same inode number]
No comments:
Post a Comment