当前位置:网站首页>The difference between soft link and hard link and how the file system takes files
The difference between soft link and hard link and how the file system takes files
2022-07-21 16:18:00 【Everything is lovely 33】
Catalog
One . The difference between soft link and hard link
Two . File system fetches files
One . The difference between soft link and hard link
1. How it was created
How to create soft links :ln -s target link_name ( Soft links can link files or folders , Often used to link folders )
How hard links are created :ln target link_name ( Hard links can only link files , Cannot link folder )
2. Hard links :
It's equivalent to an alias . New will not be created inode Number , The linked file and the source file share the same inode Number , Just add one to the number of references in the source file ;
If you delete the source file , Linked files can still be used ;
The file type of the linked file and the source file are the same ;
Hard links cannot cross file systems , Soft links can ;
You cannot create hard links to nonexistent files and directories ;
3. Soft link :
amount to Windows Shortcuts on the desktop . New will be created inode Number , Source and linked files inode Different numbers ;
The number of links in the source file does not change , The number of links to the linked file is 1( Will not be referenced by the upper layer );
The file types of source files and linked files are different , The soft link file permission is 777, File attributes are identified , Access rights really depend on the permissions of the source file ;
Delete source file , Linked files cannot be accessed ;
You can create soft links to nonexistent files and directories ;
[[email protected] lianxi]# ll
Total usage 0
-rw-r--r-- 1 root root 0 7 month 20 15:22 aabb
drwxr-xr-x 2 root root 6 7 month 20 15:22 xieshan
[[email protected] lianxi]# ll -a
Total usage 4
drwxr-xr-x 3 root root 33 7 month 20 15:22 .
drwxr-xr-x. 32 root root 4096 7 month 20 15:22 ..
-rw-r--r-- 1 root root 0 7 month 20 15:22 aabb
drwxr-xr-x 2 root root 6 7 month 20 15:22 xieshan
[[email protected] lianxi]# ln aabb aabb-link
[[email protected] lianxi]# ln -s xieshan xieshan-link
[[email protected] lianxi]# ll -a
Total usage 4
drwxr-xr-x 3 root root 70 7 month 20 15:23 .
drwxr-xr-x. 32 root root 4096 7 month 20 15:22 ..
-rw-r--r-- 2 root root 0 7 month 20 15:22 aabb
-rw-r--r-- 2 root root 0 7 month 20 15:22 aabb-link
drwxr-xr-x 2 root root 6 7 month 20 15:22 xieshan
lrwxrwxrwx 1 root root 7 7 month 20 15:23 xieshan-link -> xieshan
Two . File system fetches files
Inode Equivalent to file pointer , Points to a block of the physical hard disk . In fact, the file system maintains a reference count ( That is, the number of links ), As long as there are files pointing to this block , It won't disappear from the hard disk
After formatting, the disk is divided into two areas , A storage file metadata (inode), A piece of real data (block)
Folders are also files , Only what is saved in it is the directory entries corresponding to the files to be stored in this folder
Most of Linux file system ( Such as ext2、ext3) Regulations , A file consists of directory entries 、inode And data blocks :
- Catalog items : Include the file name and inode Node number .
- Inode: Also called file index node , Contains the basic information of the file and the pointer to the data block .
- Data blocks : Contains the specific content of the file .
How the file system fetches files ?
1. First , According to the file name , You will find the corresponding inode Number
2. Will be based on inode Number , from inode-table File found in table block Number
3.block There are specific data stored in , Read the contents of the file .
If it is a soft link file , Then there will be No 4 Step ,block What is stored in is not specific data , It is the name of the source file where the linked file is stored , Then according to the source file name , Repeat the three steps above , Find the real file data .
If it is a hard link file , The same as the source file will be found according to the hard link file name inode Number , Then proceed to the second and third steps , Read file data
About Inode、block、 More detailed contents of the catalog item , It is recommended to check this blog :https://www.cnblogs.com/fxh0707/p/16164674.html
边栏推荐
- What are the methods to realize timeout in go language
- . Net core load assembly assemblyloadcontext
- Imitate the widget control of VTK, and make the control that draws a rectangle
- Five reasons why developers use Klocwork for software security
- 2022护眼灯展,中医眼科调理展,山东眼睛保健展,中国眼博会
- How can traditional retail enterprises promote consumption cycle and share purchase mode to enable the development of physical enterprises?
- What aspects should we start from to learn the silver K-line chart
- What is super app? Applet has four features, you know?
- ROS从入门到精通(十) TF坐标变换原理,为什么需要TF变换?
- 2022山东视力防控大会,中国护眼产品展,济南近视矫正设备展
猜你喜欢
L'ipaylinks, un service d'intégration des paiements transfrontaliers, a remporté le prix 3A Asia de l'actif!
Dama summary (summary of data management)
c || 结构体 联合体 枚举类型
Shape and boundary-aware multi-branch model for semi-supervised medical image segmentation
Wechat vaccine appointment applet graduation project of applet completion work (6) opening defense ppt
專注跨境支付一體化服務 iPayLinks榮獲《財資》(The Asset)3A亞洲獎!
To test / development programmers: programmers who love life, don't work overtime, and are forced
EasyGBS平台设置小技巧:如何隐藏平台web页面不被访问?
Okaleido tiger NFT is about to log in to binance NFT platform, and the future market continues to be optimistic
Projection & local illumination
随机推荐
2.4 circular statements
Origin 2022 download nanny level installation tutorial
What preliminary work does the enterprise need to do to establish its own applet and app?
Wechat vaccine appointment applet graduation design of applet completion work (8) graduation design thesis template
[shutter -- actual combat] quick start shutter
2022山东视力防控大会,中国护眼产品展,济南近视矫正设备展
If no linetype is selected, the reason why cacuilinetypecombobox crashes
-Solid modeling-
Scanning code for vulnerabilities -- those that need to be rectified
[JS] dynamic rendering page
Starfish OS: create a new paradigm of the meta universe with reality as the link
这款国产API神器工具也太强了吧...让我放弃了postman
Characteristics of let keyword
What information can the real-time market of London Silver bring to people
Three structures of C language
Bank data management measures
Imitate the widget control of VTK, and make the control that draws a rectangle
LabVIEW实时监测和绘制单晶光伏板电压电流和能耗趋势
Vtk9.0.1+qt5.13 manually create four windows (mpr+3d)
Dama Chapter 4 (data architecture)