Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory that is showing up with the permission mask drwsrwsr-x. When I try to reset the permissions to 755 the S still remains.

What is the "s" and why cant I change the permissions back to 775 (drwxrwxr-x)?

share|improve this question
up vote 10 down vote accepted

The s you are seeing in the "execute" position in the user and group column are the SetUID (Set User ID on Execution) and SetGID (Set Group ID on execution) bits.

Unix file permissions are actually a 4-digit octal number SUGO

  • S controls the SetUID (4), SetGID (2) and "Sticky" (1) bits
  • U controls Read(4)/Write(2)/Execute(1) bits for the file owner
  • G controls the Read/Write/Execute bits for the file's group
  • O controls the Read/Write/Execute bits for everyone else.

You can remove the setuid bits from your directory with chmod ug-s directory, or chmod 0755 directory

For more information see the man page for chmod, and this Wikipedia page about the SetUID bit.

share|improve this answer
It's "sgid" (no "u"). – Dennis Williamson Feb 23 '11 at 2:41
"what is the drwsrwsrwx?" <- check again – Hrvoje Špoljar Feb 23 '11 at 11:44
chmod 0755 does not clear the setuid bit, at least not on Linux. I'm currently testing on other systems. – FUZxxl Mar 23 '15 at 13:24
POSIX says that it's implementation defined for file types other than regular files whether chmod with an octamal mode clears the setuid, setgid and vtx bits. – FUZxxl Mar 23 '15 at 13:27

setuid and setgid

setuid and setgid (short for set user ID upon execution and set group ID upon execution, respectively) are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group. They are often used to allow users on a computer system to run programs with temporarily elevated privileges in order to perform a specific task. While the assumed user id or group id privileges provided are not always elevated, at a minimum they are specific.

Run to delete setuid and setgid:

chmod 0775 path
share|improve this answer
It's on directory not file – Hrvoje Špoljar Feb 23 '11 at 1:34
a directory is also a file in a unix filesystem, what ooshro says is completely correct – lynxman Feb 23 '11 at 1:35
yes it's all a file, but the description does not fit as you dont execute something that looks like drwxrwxr-x :| – Hrvoje Špoljar Feb 23 '11 at 1:37
In unix, the inode is the thing that gets the permissions. – chris Feb 25 '11 at 2:48
GNU chmod does not clear the setuid and setgid bytes on directories when you execute it with an octamal mode. POSIX allows this behaviour. – FUZxxl Mar 23 '15 at 13:28

Adding to ooshro's answer...

If you use suid or sgid permissions on a directory, any files created inside that directory will have the same owner (if suid) or group (sgid) as the directory in question.

I use that for my home Samba share. The base directory is owned by user nobody and group olympia, and the permissions are 2770. So you have to be in the group olympia to read or write anything below that directory, and it will make sure olympia is the owning group of everything below it. I also have Samba configured to use a dirmask of 2770 and a filemask of 660 to keep the permissions correct all the way down the tree.

share|improve this answer

To remove SUID or SGID from Directories using the numeric mode, an administrator should use an extra 0 digit in their octal permissions, for example:

chmode 00755 TargetDirectory/

share|improve this answer
This does not add anything to the previous answers. – Law29 May 18 at 20:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.