Files

MacOSX 上的文件模式

  • October 21, 2016

我熟悉定義使用者、組和其他權限的 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

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)

引用自:https://unix.stackexchange.com/questions/317855