作家
登录

用户指南:Linux文件系统的链接

作者: 来源: 2017-12-04 15:07:52 阅读 我要评论

  •  
  •   total 16  
  •  
  •   -rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt  
  •  
  •   -rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt  
  •  
  •   -rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt 
  • 留意,该目次下的每个硬链接必须应用不合的名称,因为同一目次下的两个文件不克不及拥有雷同的文件名。试着创建一个和现存链接名称雷同的硬链接。

    1. [dboth@david temp]$ ln main.file.txt link2.file.txt  
    2.  
    3.  ln: failed to create hard link 'link2.file.txt': File exists 

    显然不可,因为 link2.file.txt 已经存在。今朝为止我们只在同一目次下创建硬链接,接着在临时目次的父目次(你的主目次)中创建一个链接。

    1. [dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main* 
    2.  
    3. -rw-rw-r--    4 dboth dboth     7 Jun 13 07:34 main.file.txt 
    1. [dboth@david temp]$ touch unlinked.file ; ls -l 
    2.  
    3.     total 12 
    4.  
    5.     -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt 
    6.  
    7.     -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt 
    8.  
    9.     -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt 
    10.  
    11.     -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file 

    应用 ls 敕令的 i 选项查看 inode 的硬链接号和新创建文件的硬链接号。 

    留意膳绫擎文件模式左边的数字 657024 ,这是三个硬链接文件所指的同一文件的 inode 号,你也可以应用 i 选项查看主目次中所创建的链接的节点号,和该值雷同。而那个只有一个链接的 inode 号和其他的不合,在你的体系上看到的 inode 号或许不合于本文中的。

    1. [dboth@david temp]$ df -h > link2.file.txt ; ls -li 
    2.  
    3.    total 12 
    4.  
    5.    657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt 
    6.  
    7.    657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt 
    8.  
    9.    657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt 
    10.  
    11.    657863 -rw-rw-r-- 1 dboth dboth    0 Jun 14 08:18 unlinked.file 

    如今所有的硬链接文件大年夜小都比本来大年夜了,因为多个目次项都链接着同一文件。


      推荐阅读

      七种IoT设备安全检测报告:教你几招辨别物联网设备安全性的简单方法

    CTO练习营 | 12月3-5日,深圳,是时刻成为优良的技巧治理者了 背景介绍购物热季光降了,今天我们谈一下物联网设备的安然问题。各大年夜供给商们陆续推出了很多令人高兴的物联网设备,并许琶>>>详细阅读


    本文标题:用户指南:Linux文件系统的链接

    地址:http://www.17bianji.com/lsqh/39426.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)