Linux difference between soft and hard-wired link

To address shared files, Linux system introduces two links: a hard link and soft link. Links to solve the shared file system Linux, but also brought a hidden file path, permission to increase security and save storage and other benefits. If an inode number corresponding to multiple file names, these files are called hard links. In other words, a hard link is the same file used multiple aliases. Ln command links can be created.
 
word description:
Describe the differences under Linux soft links and hard links
In the Linux system, the link is divided into two, one is a hard link (hard link), the other is called a symbolic link or a soft link (soft link or symbolic Link).
① created:
By default, with no arguments next, ln create a hard link, ln command with the -s parameter to create a soft link.
ln command can not create hard links to directories, but you can create a soft link. Soft link to the directory will be frequently used.
You can create a soft link to the file or directory does not exist, can not create hard links.
② About inode:
The same inode number of hard links and source files, and inode number of soft link to the file, the source file is different
③ Delete:
Delete soft link file, without any impact on the source files and hard linked files.
Deleted files hard-linked files, without any impact on the source file and the soft link file.
Delete the source files linked files, no effect on the hard-linked files, it will lead to a soft link failure (red and white flashes like).
Also delete the source files and the hard link file, the entire file will not actually be deleted.
④ snapshot feature many hardware devices, using the hard link is similar principle.
⑤ soft links can span file systems, hard links can not cross file system.
 
verification:
① create links
[root@luc ~]# mkdir test
[root@luc ~]# cd test/
Of file
[root@luc test]# echo source111 >> test_link
[root@luc test]# ln -s test_link link_soft
[root@luc test]# ln test_link link_hard
Directory exists
 
There is no file to create hard and soft links
 
② about the inode
 
Source files and hard links to the same inode number is 16784637
And software that links different
③ Delete
Delete soft links and hard links, no effect on the source file
 
Delete files, soft link failure
 
supplement:
Modify any links will modify the source file
 
 

Guess you like

Origin www.cnblogs.com/chenyun1/p/12563239.html