Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand Linux system link files

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to understand the Linux system link file, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Introduction to Linux system link file

Earlier, I introduced the file types of the Linux system, in which I mentioned the file type that begins with l-linked files.

The linked file in linux system is basically similar to the shortcut in WIN system, and the linked file in linux is divided into hard link and soft link.

Hard link: refers to the link through the index node, in the system, multiple files point to the same index node, is normally allowed, in this case the file is called hard link. In the actual production environment, users can prevent the misdeletion of important data by means of hard links.

Soft link: also known as symbolic link (shortcut), it is actually a text file that stores location information that points to the source file link

The method of creating a linked file

Ln source file name link file name create hard link file

Ln-s source file name link file name create soft link file

The difference between hard links and soft links

We add the content "ni hao hello world" directly to the linajie file.

As can be seen from the above figure, when the source file is deleted, the user cannot view the contents of the source file through the soft link file, but the contents of the source file can be read normally through the hard link file, so, the hard link file actually creates an alias file for the source file (it can also be considered to be the same file), while the soft link file creates an access link point for the source file.

As can be seen from the above figure, the Inode number of the source file and the hard link file is the same as 1703962, but the Inode number of the soft link file is different from that of the source file.

So the question is, are there any hard links and soft files in the directory?

What do you really want to do? please look at the picture and talk (no picture, no truth)

You can see that directories cannot create hard-link files, but you can create soft-link files

So the question comes again, since hard links can't be created, why is the number of links in the directory ceshi 2? Why is that?

That's because the number of links in the directory is 2 by default, because "." The current directory is linked to each other

They have the same Inode number 1703971, ".." is a higher-level directory, so it is the same as the upper-level directory Inode number of the current directory.

Summary:

Files and linked files

1. When the source file is deleted, the hard-linked file is used normally, and the soft-linked file is invalid.

2. When deleting the hard link, it has no effect on the source file and the soft link

3. When deleting a soft link, it has no effect on the source file and the hard link.

4. After deleting the source file and hard link file, the whole file will be deleted.

Directories and linked files

1. A directory cannot create a hard link file, so you can create a soft link file.

2. the soft link of the directory is very practical in the production environment.

3. All directories have a hard link, and directory hard links cannot span the file system.

After reading the above, have you mastered how to understand Linux system link files? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report