ls
和的文件权限lsattr
相同:
debian@debian:~$ ls -al /usr/bin/ls
-rwxr-xr-x 1 root root 147176 Sep 24 2020 /usr/bin/ls
debian@debian:~$ ls -al /usr/bin/lsattr
-rwxr-xr-x 1 root root 14496 Jun 7 2021 /usr/bin/lsattr
为什么 lsattr 无法读取文件上的标志/etc/shadow
?
debian@debian:~$ ls -al /etc/shadow
-rw-r----- 1 root shadow 1494 Jul 13 17:46 /etc/shadow
debian@debian:~$ lsattr -al /etc/shadow
lsattr: Permission denied While reading flags on /etc/shadow
答案1
下面你可以发现一个文件只有其所在目录的读取和执行权限,但对该文件没有权限。
#↳ stat /etc/shadow
File: /etc/shadow
Size: 1862 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 393275 Links: 1
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
Access: 2023-07-14 21:17:01.226553695 +0100
Modify: 2022-08-26 20:10:51.553518102 +0100
Change: 2022-08-26 20:10:51.553518102 +0100
Birth: 2022-08-26 20:10:51.553518102 +0100
lsattr
正在尝试获取更多信息。
(现代系统可能还可以获得其他信息。例如 FACL)