Two ways to link in Linux

Source: Internet
Author: User

The Linux system includes two ways of linking: Hard link and symbolic link (symbolic link), in which the link is the so-called soft link (soft link), then what is the difference between the two?

Inode

In a Linux system, the kernel allocates an inode for each newly created file, each with a unique inode, where the inode is simply understood as a pointer, which always points to the exact location of the file and the file attributes are stored in the inode, such as owner. When a file is accessed, the inode is copied to memory for quick access to the file. The system locates each file through an inode.

Hard Link

Hard Lin can be understood as a pointer that points to the inode of the source file and does not produce a new inode. Hard link no matter how many, are pointing to the same inode node, but a new hard link will increase the number of node connections, as long as the node is not 0 connections, the file is always there, regardless of whether you delete the source files or connected files. As long as there is a existence, the file exists (in fact, it refers to the concept of counter). When you modify the source file or any one of the connection files, the other files will be changed synchronously. A visible example.

Symbolic Link

Symbolic Link has a separate inode, which is a standalone file, and the content of the file is a path pointer to the source file, so you can access the source file through symbolic, so deleting the symbolic link has no effect on the source file, but the source file is deleted. The symbolic link file cannot find the file to which it is pointing. This can be imagined as a shortcut in Windows.

Compare

1. The symbolic link and the source file operation permissions are different; the hard link is exactly the same as the source file operation.
2. Symbolic links can cross file systems (partitions), and because of the limitations of inode and the ability of the file system to unload, hard links do not allow cross-file systems.
3. Symbolic links can be linked to a nonexistent file name, hard links are not available.
4. Symbolic links can be connected to the directory, hard links are not available.

Two ways to link in Linux

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.