Home > Operation and Maintenance > CentOS > What is the difference between soft links and hard links in centos

What is the difference between soft links and hard links in centos

青灯夜游
Release: 2022-02-07 16:09:00
Original
2478 people have browsed it

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.

What is the difference between soft links and hard links in centos

#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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template