Deep in chmod

There’s actually 4 attribute sets you can work with via chmod.

Special, User/Owner, Group, and Others in that order, when working with the four-number chmods, with that first number being special bits that can be set.

chmod 4555 equates to the following:

  • Set UID bit – Run the file as the owner regardless of which user is running it
  • User/Owner: Read, Execute
  • Group: Read, Execute
  • Others: Read, Execute

The s in your ‘human readable’ string for permissions indicates that the SetUID bit (explained below) is set.


 

Effectively, we can break down the four-number chmod permissions argument into specific descriptors as follows, and doing the math to determine what a 4 in the first section would be, a 5 in the next section, and so on.

Keep in mind that #### is Special  User/Owner  Group and Others in that order.

For Special attributes (the first number in a four-number chmod argument):

  • Set UID – Run file as owner regardless of the user running it (shows as s in the
    human-readable permissions string for User section) = +4
    (–s under User/Owner)
  • Set GID – Run file as group regardless of the user/group running it (shows as s in the human-readable permissions string for Group section) = +2 (–s under Group)
  • Sticky Bit – EFFECTIVE ON DIRECTORIES ONLY – If set, only the directory’s owner user and root can delete the directory, and only the file owner or root can delete files
    inside it. (shows as t in the human-readable permissions string for Others section) = +1 (–t under Others)

For User/Owner, Group and Others attributes (the last three numbers in a four-number chmod argument):

  • Read = +4 (r–)
  • Write = +2 (-w-)
  • Execute (for files), or ‘Enter Into / List Items’ (for directories) = +1 (–x)

 

More Infor on LinuxHandbook

Was this article helpful?

Related Articles

Leave A Comment?