In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what the link file under Linux means. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Linked files are an advantage of the Linux file system. If you need to maintain two or more copies of the same file on the system, in addition to saving multiple separate physical files, you can keep one copy of the physical file and multiple virtual copies, and this virtual copy becomes a link. A link is a placeholder in a directory that points to the real location of a file.
On the explanation of soft-hard connection
Hard connection
Hard join refers to the connection through the index node. In Linux's file system, a file saved in a disk partition, regardless of type, is assigned a number called an index node number (Inode Index). In Linux, it is possible for multiple file names to point to the same index node, and this kind of connection is usually a hard connection. The purpose of a hard connection is to allow a file to have multiple valid pathnames, so that users can establish a hard connection to important files to prevent "accidental deletion". The reason is as mentioned above, because there is more than one connection to the index node of the directory, deleting only one connection does not affect the index node itself and other connections, and only when the last hard connection is deleted, the connection between the data block of the file and the directory will be released. In other words, the condition for a file to be really deleted is that all hard-connected files associated with it are deleted.
Soft connection
Symbolic connection (Symbolic Link), also known as soft connection. Soft-link files are also similar to Windows shortcuts. It is actually a special file. In a symbolic link, the file is actually a text file that contains the location information of another file.
Deepen understanding through experiments
Create different types of file connections
Root@Orangepi:~/test# touch file1 # create a test file root@Orangepi:~/test# ln file1 file2 # create a hardlink file for file file2root@Orangepi:~/test# ln-s file1 file3 # create a symbolic link file for file file3root@Orangepi:~/test# ls-li #-l parameter output file information in a single column format -I inode node information of the output file total 028125-rw-r--r-- 2 root root 0 Feb 16 08:29 file128125-rw-r--r-- 2 root root 0 Feb 16 08:29 file231463 lrwxrwxrwx 1 root root 5 Feb 16 08:30 file3-> file1
As you can see from the above results, the inode node of the hardwired file file2 is the same as that of the original file file1, both 28125, but the inode node of the symbolic link file is different.
Operate on the file separately
Root@Orangepi:~/test# cat > > file1 > 12345 > EOFroot@Orangepi:~/test# cat file1 # output file file1 content 12345root@Orangepi:~/test# cat file2 # output file file2 content 12345root@Orangepi:~/test# cat file3 # output file file3 content 12345root@Orangepi:~/test# rm file1 # deletion File file1root@Orangepi:~/test# cat file212345root@Orangepi:~/test# cat file3cat: file3: No such file or directory
As can be seen from the above test: when the original file file1 is deleted, the hardlink file file2 is not affected, but the symbolic link file file1 is invalid.
This is the end of this article on "what is the meaning of linked files under Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.