加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 根目录下的父目录列表

发布时间:2020-12-14 01:02:48 所属栏目:Linux 来源:网络整理
导读:众所周知.每个Unix目录都包含特殊目录 – current(.)父(..). Unix中的顶级根目录也称为“/”. 当我在根目录中尝试时, $ls -ia 2 . 2 .. 3963 bin............... (…) (..)具有相同的inode编号 安培;执行 $cd .. 在根目录结束于同一位置. 我的问题是为什么甚
众所周知.每个Unix目录都包含特殊目录 – current(.)&父(..). Unix中的顶级根目录也称为“/”.

当我在根目录中尝试时,

$ls -ia
         2 .                    
         2 .. 
      3963 bin

...............

(…)& (..)具有相同的inode编号

&安培;执行

$cd ..

在根目录结束于同一位置.

我的问题是为什么甚至根目录都包含特殊的目录列表(..)?在根目录中列出(..)的需要是什么?

解决方法

简单地说,就是保持约定一致.

根据POSIX定义

3.144 Empty Directory

A directory that contains,at most,directory entries for dot and
dot-dot,and has exactly one link to it (other than its own dot entry,
if one exists),in dot-dot. This definition is repeated with different
phrasings in the POSIX descriptions of all file-commands.

来自超级用户answer:

This above convoluted definition for an Empty Directory is apparently behind this funny convention,and its purpose is to avoid any exceptions to the rule,not even for slash (/) i.e. root dir.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读