coreutils: Numeric Modes
1
1 27.3 Numeric Modes
1 ==================
1
1 As an alternative to giving a symbolic mode, you can give an octal (base
1 8) number that represents the mode.
1
1 The permissions granted to the user, to other users in the file’s
1 group, and to other users not in the file’s group each require three
1 bits: one bit for read, one for write, and one for execute/search
1 permission. These three bits are represented as one octal digit; for
1 example, if all three are present, the resulting 111 (in binary) is
1 represented as the digit 7 (in octal). The three special mode bits also
1 require one bit each, and they are as a group represented as another
1 octal digit. Here is how the bits are arranged, starting with the
1 highest valued bit:
1
1 Value in Corresponding
1 Mode Mode Bit
1
1 Special mode bits:
1 4000 Set user ID on execution
1 2000 Set group ID on execution
1 1000 Restricted deletion flag or sticky bit
1
1 The file's owner:
1 400 Read
1 200 Write
1 100 Execute/search
1
1 Other users in the file's group:
1 40 Read
1 20 Write
1 10 Execute/search
1
1 Other users not in the file's group:
1 4 Read
1 2 Write
1 1 Execute/search
1
1 For example, numeric mode ‘4751’ corresponds to symbolic mode
1 ‘u=srwx,g=rx,o=x’, and numeric mode ‘664’ corresponds to symbolic mode
1 ‘ug=rw,o=r’. Numeric mode ‘0’ corresponds to symbolic mode ‘a=’.
1
1 A numeric mode is usually shorter than the corresponding symbolic
1 mode, but it is limited in that normally it cannot take into account the
1 previous file mode bits; it can only set them absolutely. The
1 set-user-ID and set-group-ID bits of directories are an exception to
1 this general limitation. ⇒Directory Setuid and Setgid. Also,
1 operator numeric modes can take previous file mode bits into account.
1 ⇒Operator Numeric Modes.
1
1 Numeric modes are always interpreted in octal; you do not have to add
1 a leading ‘0’, as you do in C. Mode ‘0055’ is the same as mode ‘55’.
1 However, modes of five digits or more, such as ‘00055’, are sometimes
1 special (⇒Directory Setuid and Setgid).
1