I understand there are 12 permission bits of which there are 3 groups of 3 bits for each of user, group, and others, which are RWX respectively. RW are read and write, but for X is search for directories and execute for files.

Here is what I don't get:

  1. What are the 3 remaining mode bits and are they all stored in the inode?

  2. I know the file directory itself is considered a file as well, since all things in UNIX are files (is this true?), but since UNIX systems use ACL to represent the file system, then the file system is a list of filename-inode_number pairs. Where does a file directory store it's own inode number and filename?

  • This answer should cover the first part of your first question. Commented Jun 1, 2018 at 14:46
  • Thanks Stephen. As a matter of fact I have read the answer before but I'm a little dense at this so I didn't get a clue about the last 3 bits.. The closest thing I can infer from that answer is 3 bits can represent 0 to 7, and there are 4 values that can set permissions apparently (like 0777), and each number in each position represent some permission?
    – winnie99
    Commented Jun 1, 2018 at 15:09
  • The 0 (first digit) in your example (0777) references the suid, sgid and "sticky" bit per Stephen's link. The first 7 (second digit) is the 3 bits (RWX) of the owner's permissions. The second 7 (third digit) is the 3 bits of the group's permissions. The final 7 (fourth digit) is the 3 bits of the others' permissions. You're correct in understanding that 3 bits together can represent a number from 0 to 7. Commented Jun 1, 2018 at 15:27

2 Answers 2


stat /bin/su shows on one system:

Access: (4755/-rwsr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

There's the octal representation 4755 of all 12 mode bits. The number corresponds to the bits:

octal    4   7   5   5
bits   100 111 101 101
       sst uuu ggg ooo
       ug  rwx rwx rwx

Where uuu, ggg and ooo are the permission bits for the user, group and others. The remaining group (the first one in order) contains the setuid (su), setgid (sg) and sticky (t) bits.

The setuid and sticky bits are often not mentioned, since they're zero for most files. They're still there for every file, saved along with the others.

If we really get down to it, some filesystems and interfaces store the file type along the mode bits, in the still-higher bits. The above only accounts for 12 bits, so with a 16-bit field, there's 4 left over. See, for example, the description of st_mode in stat(2).

  1. The remaining three bits represent the setuid, setgid and sticky bits; see Understanding UNIX permissions and file types for details. These are all stored in the inode.

  2. A directory is indeed a sort of file storing a list of names and corresponding inodes. A directory’s own name and inode are stored in its parent directory; the root directory is a special case, it is typically a fixed inode in the file system (inode 2 in Ext4) and is of course always named / (which ends up being relative to its mount point...).

  • The root is a different case. In this case EXT file systems add the root directory inode as part of the file system itself. I think this shall be added in order to complete the answer. BTW: I don't know the internals of other file systems, but they might be the same.
    – D4RIO
    Commented Jun 1, 2018 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .