3

if I use stat command I see this "0" appearing in "Access" : for example Access: (0644/-rw-r--r--). After some research, I think this value is linked to what is known as "Special permission" : https://www.baeldung.com/linux/umask. Incindentally I found this comment on https://www.debian.org/doc/manuals/debian-handbook/sect.rights-management.en.html :

Two particular rights are relevant to executable files: setuid and setgid (symbolized with the letter “s”). Note that we frequently speak of “bit”, since each of these Boolean values can be represented by a 0 or a 1. These two rights allow any user to execute the program with the rights of its owner or its group, respectively. This mechanism grants access to features requiring higher level permissions than those you would usually have.

Could you give me a concrete example of a situation where this "special permission" is used and set to "1" or any other value?

1
  • I think I've found an explanation of how special permissions work linuxconfig.org/… . But what does this have to do with the first "0" of umask value or the stat command? Does it only mean "there is no special permission set" for this file or directory in access (stat command) and "there is no change to make" in *umask?
    – mazda
    Commented Dec 9, 2023 at 9:57

1 Answer 1

3

The first octal digit in the mask, when four digits are given, specifies the optional special permissions of the file/folder, which are called setuid, setgid, and the sticky bit:

  • setuid: a bit that makes an executable run with the privileges of the owner of the file
  • setgid: a bit that makes an executable run with the privileges of the group of the file
  • sticky bit: a bit set on directories that restricts deletions only to the owner or root.

From chmod(1) man :

A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Omitted digits are assumed to be leading zeros. The first digit selects the set user ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes.

Example reference : How Do I Set Up Setuid, Setgid, and Sticky Bits on Linux?

2
  • You may, in a historical context, see remarks of the use of the sticky bit on executables. That did keep parts of the program in memory, which would speed-up the program. This use has been abandoned. Commented Dec 9, 2023 at 13:07
  • "Example reference" helps. Thanks.
    – mazda
    Commented Dec 16, 2023 at 3:10

You must log in to answer this question.

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