Differences: 1. Source files and hard link files have the same Inode and Block, while soft links and source files have different Inodes and Blocks; 2. Hard links cannot link directories, while soft links can link directories; 3. Hard links cannot cross partitions, but soft links can cross partitions.
#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.
centos7-hard link and soft link
Hard link characteristics
- Source Files and hard link files have the same Inode and Block
- Modify any file, the other will change
- Delete any file, and the other one can use
- Hard link The mark is unclear and it is difficult to confirm the location of the hard link file. It is not recommended to use it
- Hard links cannot link directories
- Hard links cannot cross partitions
Soft Link characteristics
- Soft links and source files have different Inodes and Blocks
- If any one of the two files is modified, the other will change
- Delete the soft link Link, the source file is not affected; delete the source file, soft link cannot be used
- Soft link has no actual data, only the Inode of the source file is saved, no matter how big the source file is, the size of the soft link remains unchanged
- The permissions of soft links are the maximum permissions, but since there is no actual data, you need to refer to the source file permissions for final access
- Soft links can link directories
- Soft links can cross partitions
- Soft link features are obvious, it is recommended to use soft link
Link command ln
ln [选项] 源文件 目标文件
Copy after login
-s: Create a soft link file. If you do not add the "-s" option, a hard link file will be created
-f: mandatory. If the target file already exists, delete the target file and then create the link file
Recommended: "centos usage tutorial"
The above is the detailed content of What is the difference between soft links and hard links in centos. For more information, please follow other related articles on the PHP Chinese website!