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

What is the concept of Linux hard link and soft link

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "what is the concept of Linux hard link and soft link". In daily operation, I believe that many people have doubts about the concept of Linux hard link and soft link. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "what is the concept of Linux hard link and soft link?" Next, please follow the editor to study!

Hard link

A hard link is a link made through an index node. In Linux, it is allowed that multiple files point to the same index node, and links like this are hard links. Hard links can only be linked between files in the same file system, not directories. If the source file corresponding to the hard link is deleted, the hard link file still exists and the original content is saved, which can prevent the file from being deleted by mistake. Because hard links are files with the same inode number but different file names, deleting one hard link file does not affect other files with the same inode number.

Hard links can be created by the command link or ln, such as:

Link oldfile newfileln oldfile newfile symbolic link

A soft link (also known as a symbolic link) is different from a hard link in that the content stored in the user data block of the file is the point to the pathname of another file. A soft link is an ordinary file, but the content of the data block is a little special. Soft links can be created for files or directories.

Soft links are mainly used in the following two aspects: first, it is convenient to manage, for example, files under a complex path can be linked to a simple path for users to access; on the other hand, it is to solve the lack of disk space in the file system. For example, a file system has run out of space, but now it is necessary to create a new directory under the file system and store a large number of files. Then you can link the directory in another file system with more space to the file system, which can solve the problem of insufficient space. Deleting a soft link does not affect the file being pointed to, but if the original file is deleted, the relevant soft link becomes a dead link.

Symbolic links can be created using the ln command with the-s option, as follows:

Ln-s old.file soft.linkln-s old.dir soft.link.dir extension

The inode is called the Inode number, which is how the Linux file system manages files. When a file system is created, an index node table is created that contains a certain number of index nodes. Whenever a file is created, it is assigned an index node number, which is equivalent to the address of the file.

At this point, the study of "what is the concept of Linux hard links and soft links" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report