Summary of linux soft connection PK hard connection

Source: Internet
Author: User
Summary of linux soft connection PK hard connection-Linux general technology-Linux programming and kernel information. The following is a detailed description. In Linux, I often see soft connections and hard connections. In particular, there are many soft connections, but I still don't quite understand them. I checked them online today and many people are just like me, being depressed, haha, there is no research into things that are too deep. At the usage level, I will make a simple summary of these two things to facilitate my memory, you can also help other depressed siblings. If you have any questions, please correct them. Haha.

Let's talk about soft connections first. I think this is a better understanding, and I think it is also because of the soft pinch of persimmons. Haha, create a soft connection command: [ln-s source file name soft connection file name ], you can use the ls command to view the file information and verify that you can create a soft connection to both files and directories. on the Internet, we can see many people say that the shortcut is a metaphor. I personally think it is more visual, creating a soft connection is to create a shortcut for the specified file, which only records the path of the source file. When used, the source file is used indirectly, regardless of the specific implementation, this is simple in terms of use. If the source file is deleted, this soft connection will be useless. Because there are no files or folders under the recorded path, the effect will be lost with the exe in windows, double-click shortcuts have the same effect. Because soft connections only record a path, they can be used across file systems.

Then, create a hard connection command: [ln-d source file name Hard connection file name ]. Each file accessed in Linux has an inode node, which contains a connection count, which is not involved in soft connections, if a hard connection is created for a file, the inode connection count corresponding to the file is increased by 1. In this case, the inode file has two names for access, the two names are the same now. You can use any one to continue creating a hard connection. Therefore, the created hard connection is the same as the source file, sharing the same inode, if one is deleted, the connection count is reduced by 1. If the number of connections is 0, the file is deleted. Otherwise, the delete operation only reduces the connection count by 1. Hard Connections cannot be created across file systems, and can only be created for files. Hard Connections cannot be created for directories.

Like a hard connection, a read/write soft connection operates on the same file. I still want to explain it in a few diagrams. After a long time, I didn't get one. Haha, so I'm sorry, let's take a look!

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.