如何查看特定目录的权限?


13

我知道我可以ls -l用来列出目录中的所有文件,包括它们的权限,但是如何查看特定目录的权限。例如,如果我想查看/etc目录的权限?

Answers:


18

-d像这样添加到命令:

ls -ld /etc

来自man ls

   -d, --directory
          list directory entries instead of contents, and do not dereference symbolic links

7

您也可以使用stat命令获取特定文件或目录的权限:

 stat -c "%A %n" Directory-or-File

或八进制模式的权限:

 stat -c "%a %n" Directory-or-File
  • -c选项允许您自定义输出。
  • 文件名显示为的结果%n%a显示八进制权限,并%A以可读格式显示权限。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.