
我熟悉定義使用者、群組和其他權限的 3 個檔案模式“位元”以及 setuid/setgid/sticky“位元”,但是當我查看stat
MacOSX 筆記型電腦上的根級目錄時,我會看到1 到2 個額外的權限字段。這些是什麼?
[onlyanegg@macosx ~]$ stat -f '%p %N' /*
40775 /Applications
40755 /Library
40755 /Network
40755 /System
40755 /Users
41777 /Volumes
40755 /bin
41775 /cores
40555 /dev
120755 /etc
40555 /home
100644 /installer.failurerequests
40555 /mnt
40555 /net
40775 /opt
40755 /private
40755 /sbin
120755 /tmp
40755 /usr
120755 /var
答案1
stat(1)
指定%p
請求
文件類型和權限。
(在連結頁面中尋找「資料」)。顯示的值是全部st_mode
(參見stat(2)
:
#define S_IFMT 0170000 /* type of file */ #define S_IFIFO 0010000 /* named pipe (fifo) */ #define S_IFCHR 0020000 /* character special */ #define S_IFDIR 0040000 /* directory */ #define S_IFBLK 0060000 /* block special */ #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ #define S_IFWHT 0160000 /* whiteout */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* save swapped text even after use */ #define S_IRUSR 0000400 /* read permission, owner */ #define S_IWUSR 0000200 /* write permission, owner */ #define S_IXUSR 0000100 /* execute/search permission, owner */
這解釋了您獲得的值:
- 以 4 開頭的值是目錄 (
/Applications
,/Library
...) - 以 12 開頭的值是符號連結 (
/etc
,/tmp
,/var
) - 以 10 開頭的值是常規檔 (
/installer.failurerequests
)