如何检查根文件夹(/文件夹,而不是/root)的权限?

try*_*sis 18 permissions

有没有办法检查根文件夹的权限,/?我的意思是文件夹的权限,而不是其内容的(/var、/usr 等)权限?运行ls /..显示内容的权限。

ter*_*don 62

您还可以使用以下-d开关ls

$ ls -ld /
drwxr-xr-x 28 root root 126976 Mar 20 17:11 /
Run Code Online (Sandbox Code Playgroud)

来自man ls

   -l     use a long listing format
   -d, --directory
          list  directory entries instead of contents, and do not derefer?
          ence symbolic links
Run Code Online (Sandbox Code Playgroud)


Ram*_*esh 24

stat -c "%a %n" /

它会给你权限。


n.s*_*.st 16

使用-a开关ls包括隐藏文件以及...在列表中,-l开关用于“长”列表(包括权限和其他信息):

ls -la /
Run Code Online (Sandbox Code Playgroud)

.最后一列中带有单个的行将包含有关所列目录本身的信息,即/

drwxr-xr-x 26 根 4096 Mar 10 15:57 。

但是,如果您只需要有关/自身的信息,则terdon 的答案(使用-d开关)可能会更方便。

  • 这不是一个很好的解决方案,当所有 OP 想要的都是 `/` 本身时,它会列出 `/` 下的所有文件。请参阅以下答案中的 `stat` 或 `ls -ld`。 (2认同)
  • `.` 不一定是第一。该列表按词法排序。在许多语言环境中,有几个字符排在 `.` 之前。 (2认同)