Softlink and Hardlink under Linux

Source: Internet
Author: User

There are two types of links in Linux: Hard links and soft links (soft link), and soft links called Symbolic links (symbolic link)

To create a command:
Ln-s destfile/directory Softlink #建立软连接
ln destfile hardlink #建立硬连接

Inode
In a Linux system, the kernel allocates an inode for each newly created file, each with a unique inode number, and we can simply interpret the inode as a pointer that will always point to the specific storage location of the file. File attributes are stored in the inode, and when the file is accessed, the inode is copied to memory for fast file access. The system locates each file through an inode.

Hard link
Hard links are actuallyA pointer, point to the inode of the source file, and the system does not redistribute the inode for it. Hard Connectno new inode is created, a hard connection, no matter how many, is pointing to theSame Inode node, just create a new hard link to increase the number of node connections, as long as the junction number of connections is not 0, the file exists, regardless of whether you delete the source file or the connected file.
As long as there is a existence, the file exists (in fact, it isReference CountConcept). When you modify the source file or any one of the connection files, the other files will beSynchronized Modifications

Soft links (soft link)
Soft links The most intuitive explanation: equivalent to the Windows system shortcuts, is aStandalone File(withan independent inode, regardless of the source file inode), the content of the file is the path pointer to the source file, which can be accessed through the link to the source file. So delete the soft link file has no effect on the source file, but delete the source file, the soft link file will not find the file to point to (You can analogy Windows shortcut, you click the shortcut can access a file, but delete the shortcut, no effect on the source file).

Difference
1. Soft link and source file operation permissions are different; the hard link is exactly the same as the source file operation.
2. Soft links can cross file system (partition); Because of Inode limitations and file system offload, hard connections do not allow cross-file systems.
3. A soft connection can connect to a nonexistent file name, and a hard link is not available.
4. The soft connection can be connected to the directory, hard links are not available.

Softlink and Hardlink under Linux (RPM)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.