这是简短的答案:
$ ls -ld directory
这是它的作用:
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
您可能对 manpages 感兴趣。这就是这里所有的人都能得到他们好的答案的地方。
如果您需要有关文件/目录的详细信息,也可以使用 stat
命令。 (正如你所说的那样,我准确地说你正在学习^^)
stat -f %A dir_or_filename
。
$ ls -ld directory
ls
是列表命令。
-
表示命令选项的开始。
l
要求提供包含权限的长列表。
d
表示列表应该与命名目录本身有关;不是它的内容。如果没有给出目录名称,则列表输出将与当前目录有关。
在 GNU/Linux 中,尝试使用 ls
、namei
、getfacl
、stat
。
对于目录
[flying@lempstacker ~]$ ls -ldh /tmp
drwxrwxrwt. 23 root root 4.0K Nov 8 15:41 /tmp
[flying@lempstacker ~]$ namei -l /tmp
f: /tmp
dr-xr-xr-x root root /
drwxrwxrwt root root tmp
[flying@lempstacker ~]$ getfacl /tmp
getfacl: Removing leading '/' from absolute path names
# file: tmp
# owner: root
# group: root
# flags: --t
user::rwx
group::rwx
other::rwx
[flying@lempstacker ~]$
或者
[flying@lempstacker ~]$ stat -c "%a" /tmp
1777
[flying@lempstacker ~]$ stat -c "%n %a" /tmp
/tmp 1777
[flying@lempstacker ~]$ stat -c "%A" /tmp
drwxrwxrwt
[flying@lempstacker ~]$ stat -c "%n %A" /tmp
/tmp drwxrwxrwt
[flying@lempstacker ~]$
对于文件
[flying@lempstacker ~]$ ls -lh /tmp/anaconda.log
-rw-r--r-- 1 root root 0 Nov 8 08:31 /tmp/anaconda.log
[flying@lempstacker ~]$ namei -l /tmp/anaconda.log
f: /tmp/anaconda.log
dr-xr-xr-x root root /
drwxrwxrwt root root tmp
-rw-r--r-- root root anaconda.log
[flying@lempstacker ~]$ getfacl /tmp/anaconda.log
getfacl: Removing leading '/' from absolute path names
# file: tmp/anaconda.log
# owner: root
# group: root
user::rw-
group::r--
other::r--
[flying@lempstacker ~]$
或者
[flying@lempstacker ~]$ stat -c "%a" /tmp/anaconda.log
644
[flying@lempstacker ~]$ stat -c "%n %a" /tmp/anaconda.log
/tmp/anaconda.log 644
[flying@lempstacker ~]$ stat -c "%A" /tmp/anaconda.log
-rw-r--r--
[flying@lempstacker ~]$ stat -c "%n %A" /tmp/anaconda.log
/tmp/anaconda.log -rw-r--r--
[flying@lempstacker ~]$
这将显示文件及其权限
stat -c '%a - %n' directory/*
除了上面的帖子,我想指出“man ls”会给你一个很好的关于“ls”(List”命令的手册。
此外,使用 ls -la myFile 将列出并显示有关该文件的所有事实。
在 OS X 上,您可以使用:
ls -lead
e 选项显示 ACL。 ACL 对于了解系统上的确切权限非常重要。
ls -lstr
这显示了具有权限和 user:group 的普通 ls 视图
要检查文件的权限配置,请使用以下命令:
ls –l [file_name]
要检查目录的权限配置,请使用以下命令:
ls –l [Directory-name]
不定期副业成功案例分享