Linux File Types and File Modes

More info on inode manpage

File type and permission are stored as a 16-bit “value”

Higher 4-bits: for storing file type (max 16 file type possible)

Lower 12-bits: for storing permissions : for special, user, group, other : each can have 7 combinations of read-write-execute + 1 for no permission

The “value” is typically represented in octal notation.

e.g. A regular file with rwxr—r— permission will have value “0100744”, where
0 - no idea why its there
10 - regular file
0744 - file permissions

File types

Each file can have only 1 file type

( ‘x’ in the value column corresponds to file mode )

Value (octal)Notes
014xxxxsocket
012xxxxsymbolic link
010xxxxregular file
006xxxxblock device
004xxxxdirectory
002xxxxcharacter device
001xxxxFIFO

File modes

Special permissions (set UID, set GID, sticky) have higher priority over other permissions
You can combine the permissions by adding the values
e.g. 4754: set UID enabled, u=rwx, g=rx, o=r

( ‘x’ in the value column corresponds to file mode )

Value (octal)Notes
0xx4000set UID bit
0xx2000set-group-ID bit (see below)
0xx1000sticky bit (see below)
0xx0400owner has read permission
0xx0200owner has write permission
0xx0100owner has execute permission
0xx0040group has read permission
0xx0020group has write permission
0xx0010group has execute permission
0xx0004others have read permission
0xx0002others have write permission
0xx0001others have execute permission