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

Detailed explanation of Linux hard links and soft links

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor this time to share with you is a detailed explanation of Linux hard links and soft links, the article is rich in content, interested friends can come to understand, I hope you can get something after reading this article.

In the linux system, there are linked files that can be used to solve the problem of file sharing. There are two ways of linking, one is hard link (Hard Link), the other is soft link or symbolic link (Symbolic Link).

Hard link concept

A hard link (hard link) is one or more file names of a file.

Hard links refer to links through index nodes. In Linux's file system, files saved in disk partitions, regardless of type, are assigned a number called an index node number (Inode)

Index) or Inode, which is the unique identification of a file or directory in a file system. The actual data of the file is placed in the data area (data block). It stores important parameter information of the file, that is, metadata (metadata), such as creation time, modification time, file size, ownership, belonging user group, read and write permissions, block number of the data, etc.

After the hard link is established, the source file and the linked file are synchronized, and the file of either party will be modified.

Establishing links can save space, only need to maintain link relationships, and do not need to copy files

Soft link concept

Soft link (also known as symbolic link), similar to the shortcut in the windows system, different from the hard link, the soft link is an ordinary file, but the content of the data block is a little special, the content stored in the data block of the file user is the path name of another file pointing to, through this way you can quickly locate the source file entity pointed to by the soft connection. Soft links can be created for files or directories.

Soft link function:

It is convenient for file management, such as linking a file under a complex path to a simple path for users to access. Save space to solve the problem of insufficient space, a file system has run out of space, but now you must create a new directory under that file system and store a large number of files. Then you can link a directory in another file system with more space left to that file system. 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.

The essential difference between hard links and soft links

A hard link can be thought of as a file with two file names, while a soft link is a new linked file created by the system that points to the file it refers to.

Limitations of hard links

Soft links can cross the file system; hard links can not soft links can link to a file that does not exist; hard links can not be soft links can be linked to the directory, hard links can not soft links to overcome the limitations of hard links. Based on this, focus on soft links. Soft links, also known as symbolic links, are equivalent to shortcuts in windows.

Establish a soft link

Ln-s src_file ln_file

Delete soft links

Rm ln_file

Note: for directory soft training level

Rm ln_dir is to delete soft links.

Rm ln_dir/ deletes files in the directory ln_dir. Of course, files in the source directory will also be deleted (synchronized).

After reading this article about explaining Linux hard links and soft links in detail, if you think the content of the article is good, you can share it with more people.

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