Analysis and Application of differences between hard connection and file shortcuts in Unix

Source: Internet
Author: User
Article Title: differences between hard connection and file shortcuts in Unix and its application. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Users familiar with Windows operating systems must be impressed with its shortcuts? By using shortcuts, you can locate the files or directories originally stored on d disks to the desktop for convenient access. In fact, there are similar functions in Linux, but the functions are slightly better than shortcuts.

 I. Principle of hard connection.

The inode node stores file-related attributes, such as permissions. However, this node does not have the name of the storage file. This feature gives users a lot of imagination. In this case, a file has only one node, but it can have multiple file names. When a file has multiple file names, it is called a file in a Unix system that has multiple connections. You can access this file through any connection of the file. Although they have different file names, they are the same file because the inode number of their files is the same. In general, as long as the number of inode nodes is the same, it is the same file. Although there are multiple file names, there is only one file copy on the hard disk. Strictly speaking, there are not multiple files with the same number of nodes. They are just one file, but only by different names. Like a person, he can have multiple nicknames, but this person has only one unique nickname. Even if another person is generated by cloning and other technologies, they are two different people, not one person. Understanding this content has a great effect on understanding the differences between hard connection and shortcuts.

Ii. Differences between hard connection and shortcuts.

There is a big difference between hard connections and shortcuts in Unix systems. Simply put, hard connections in Unix operating systems are actually different aliases of files. The shortcuts in Microsoft operating systems are two different issues. As shown in:



File doc1 and file doc2 are the same file because they have the same number of nodes. File doc2 is a hard connection of file doc1. That is to say, this file has two nicknames. Modifications to one nickname (that is, the link) will affect another nickname. The files represented by these two nicknames may be stored in two different directories through commands such as ls, but by querying the number of their nodes, they can be found to belong to the same file.

However, shortcuts are different. As shown on the right, the file doc2 is a shortcut for the file doc1. In fact, they are two files. The file doc1 stores the content of the file, while the file doc2 stores a path pointing to the file doc1. That is to say, the two names correspond to different files. Or, the two file names represent different files. When you open the doc2 file, the system first opens the file doc2. Then read the file doc1 path from the file and open the file doc1. Because this process is transparent to users, users seem to represent the same file. They are actually different. You only need to change the file doc1 to another location. When the file doc2 is opened, the system will prompt that the file doc1 error message cannot be found. It can be determined from this that the file doc2 only saves a connection method of the file doc1, rather than the content of the file doc1 itself.

The above is the main difference between hard connection and shortcuts. This difference also determines the unique use of hard connection in some occasions.

[1] [2] [3] Next page

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.