Linux soft links and hard-link files

Source: Internet
Author: User

Below is the Linux system software underlying storage structure, we will be from the ground up to explain the Linux system under the soft and hard connection file

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/3B/wKiom1edrt6B6rLdAAD9fsgEwXs119.png "title=" Picture 1.png "alt=" Wkiom1edrt6b6rldaad9fsgewxs119.png "/>

<;: Explanation (bottom)

Hard links, in fact, from the bottom of the data, the hard link is actually added a directory entry. The underlying inode table, the values in the data area are immutable, and are not recreated.

Soft links, in fact, from the bottom of the view, the soft link is actually the equivalent of recreating a file, whether it is a catalog item, Inode table, and the data area are rebuilt, and this file function is very special, it is used to point to another file.

< two;: Use of commands

Hard-Link command:

The abbreviation that LN uses to create the link English word

A hard link is added by default in ln

ln filename Link Name

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/85/3B/wKiom1edsQ2D7uUjAAA_J938Z38307.png "title=" capture. PNG "alt=" Wkiom1edsq2d7uujaaa_j938z38307.png "/>

Create 3 hard links, 3 hard links to the bottom of the ID number is the same, so the three files point to the inode number is the same, the created file is actually just add an item in the catalog item.


Soft link command:

ln-s filename Link name//Only one-s option is required

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/85/3B/wKiom1edsnixhIxGAABJ6rpIM9U947.png "title=" Capture 1. PNG "alt=" Wkiom1edsnixhixgaabj6rpim9u947.png "/>

Create 2 soft links, 2 soft links the bottom of the ID number is not the same, so the corresponding Inode table and data block area of the two files are different.


The difference between soft links and hard links

Hard links are not allowed across file systems

A soft connection can be built across a file system

Hard links are not allowed to be created for directory files

Soft links are allowed to be created for directory files


Considerations for soft links and hard links:

When creating a soft link, there is a relative path to the problem

Ln-s the relative path of the original file (relative to the path of the soft link file) Soft link file

Ln-s File name Connection name

If the file name here is relative to the path, this is relative to the directory where the link name resides, so you have to re-write the path of the file name based on the directory where the link name resides.

To prevent an error from establishing a soft link, the file name is written as an absolute path. This is certainly not a mistake.

Linux soft links and hard-link files

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.