In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of soft links and hard links under Linux, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
1.Linux link concept
There are two kinds of Linux links, one is called Hard Link, the other is called symbolic link (Symbolic Link). By default, the ln command produces hard links.
[hard connection]
Hard connection refers to the connection through an index node. In Linux's file system, files saved in disk partitions, regardless of type, are assigned a number called index node number (Inode Index). In Linux, it is possible to have multiple file names pointing to the same Inode. Generally speaking, this kind of connection is 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 Inode itself and other connections. Only when a connection is deleted will the connection of the file's data block and directory 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]
Another kind of connection is called symbolic connection (Symbolic Link), also called soft connection. Soft-link files have shortcuts similar to Windows. It is actually a special file. In symbolic links, a file is actually a text file that contains information about the location of another file.
two。 Deepen understanding through experiments
[oracle@Linux] $touch F1 # create a test file F1 [oracle@Linux] $ln f1 f2 # create a hardlink file f2 [oracle@Linux] $ln-s f3 # create a symbolic link file f3 [oracle@Linux] $ls-li #-I parameter displays the inode node information of the file total 0 9797648-rw-r--r- -2 oracle oinstall 0 Apr 21 08:11 F1 9797648-rw-r--r-- 2 oracle oinstall 0 Apr 21 08:11 f2 9797649 lrwxrwxrwx 1 oracle oinstall 2 Apr 21 08:11 f3-> F1
As can be seen from the above results, the inode node of the hardwired file f2 is the same as that of the original file F1, both being 9797648, but the inode node of the symbolic link file is different.
[oracle@Linux] $echo "I am f1 file" > > F1 [oracle@Linux] $cat f1 I am F1 file [oracle@Linux] $cat f2 I am f1 file [oracle@Linux] $cat f3 I am F1 file [oracle@Linux] $rm-f f1 [oracle@Linux] $cat f2 I am F1 file [oracle@Linux] $cat f3 cat: f3: No such file or directory
As can be seen from the above test: when the original file F1 is deleted, the hard connection f2 is not affected, but the symbolic link F1 file is invalid.
Thank you for reading this article carefully. I hope the article "sample Analysis of soft links and hard links under Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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: 230
*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.