运维开发网

在Linux中根目录下的父目录列表

运维开发网 https://www.qedev.com 2020-05-19 10:17 出处:网络
众所周知.每个Unix目录都包含特殊目录 – current(.)&父(..). Unix中的顶级根目录也称为“/”.
众所周知.每个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.

0

精彩评论

暂无评论...
验证码 换一张
取 消