我知道使用ls -l "directory/directory/filename"告诉我文件的权限.如何在目录上执行相同操作?我显然可以ls -l在层次结构中较高的目录上使用,然后滚动直到我找到它但是这很痛苦.如果我ls -l在实际目录上使用它,它会提供其中的文件的权限/信息,而不是实际目录.我在Mac OS X 10.5和Linux(Ubuntu Gutsy Gibbon)的终端上试过这个,结果相同.我应该使用某种旗帜吗?
Joh*_*itb 398
这是简短的回答:
$ ls -ld directory
Run Code Online (Sandbox Code Playgroud)
这是它的作用:
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
Run Code Online (Sandbox Code Playgroud)
您可能对联机帮助页感兴趣.这就是所有人在这里得到他们的好答案的地方.
请参阅在线手册页
Pio*_*cki 59
stat如果需要有关文件/目录的详细信息,也可以使用该命令.(正如你所说,你正在学习^^)
Tay*_*lan 12
还有
getfacl /directory/directory/
Run Code Online (Sandbox Code Playgroud)
其中包括ACL
这里有关于Linux ACL的一个很好的介绍
小智 8
在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 ~]$
Run Code Online (Sandbox Code Playgroud)
要么
[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 ~]$
Run Code Online (Sandbox Code Playgroud)
[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 ~]$
Run Code Online (Sandbox Code Playgroud)
要么
[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 ~]$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
664368 次 |
| 最近记录: |