# chmod drwxr-s--- [solved]

## rretz

I have a question about chmod.

i know all the thing chmod 777 etc etc etc.

but i also know chmod can be used with 4 digits. and then the 's' shows up.

But what does this mean!!!!!

There is also a 'S', 't'and a 'T'

chmod 777 gives: (as we all know)  :Very Happy: 

drwxrwxrwx  2 root root 4096 Aug  7 23:08 test

f.e.

chmod 7770 gives:

drwsrws--T  2 root root 4096 Aug  7 23:08 test

chmod 7707 gives:

drws--Srwt  2 root root 4096 Aug  7 23:08 test

who can help me!!!!!

----------

## rretz

 *rretz wrote:*   

> I have a question about chmod.
> 
> i know all the thing chmod 777 etc etc etc.
> 
> but i also know chmod can be used with 4 digits. and then the 's' shows up.
> ...

 

the complete view.

archibald localhost # chmod 7000 test -v

mode of `test' changed to 7000 (--S--S--T)

archibald localhost # chmod 1000 test -v

mode of `test' changed to 1000 (--------T)

archibald localhost # chmod 2000 test -v

mode of `test' changed to 2000 (-----S---)

archibald localhost # chmod 3000 test -v

mode of `test' changed to 3000 (-----S--T)

archibald localhost # chmod 4000 test -v

mode of `test' changed to 4000 (--S------)

archibald localhost # chmod 5000 test -v

mode of `test' changed to 5000 (--S-----T)

archibald localhost # chmod 6000 test -v

mode of `test' changed to 6000 (--S--S---)

archibald localhost # chmod 7000 test -v

mode of `test' changed to 7000 (--S--S--T)

I know his, there is no iference between capitale and no capitale. The caps are only used when the other numbers are 0

----------

## widan

 *rretz wrote:*   

> but i also know chmod can be used with 4 digits. and then the 's' shows up. But what does this mean!!!!!

 

"s" is suid/sgid (suid if in the "user" part of the rights, "chmod 4xxx", sgid if in the "group" part, "chmod 2xxx"). A program that has suid (sgid) set will run with the permissions of the user (group) that owns the file.

```
widan@melanie ~ $ ls -l /usr/bin/write /bin/passwd 

-rws--x--x  1 root root 33144 Jul 30 11:06 /bin/passwd

-rwxr-s--x  1 root tty  11496 Jul 17 01:56 /usr/bin/write
```

If you run passwd, it will run with root permissions, even if you're not root (else you wouldn't be able to change your password). If you run write, it will run with the permissions of the "tty" group (that lets it write to consoles and ptys).

Also the sgid bit on a directory automatically sets the group of the files created in that directory to the group that owns the directory, no matter who creates the files.

"t" is sticky bit. It's a special flag for directories like /tmp. It means that only the owner of the directory and the user that created a file in that directory can delete it, even if other people have write access to the directory (normally, if you have write access to a directory, you can delete files in it, even if you don't own them). It only really makes sense on directories that are group- or world-writable.

 *rretz wrote:*   

> There is also a 'S', 't'and a 'T'

 

The caps represent the state of the "x" bit (which you can't see anymore when there are "special" bits). Caps mean there is no execute permission, no caps mean there is execute permission. Normally, you should never see the caps as they are mostly abnormal states, since sgid/suid only makes sense on programs, so with x bit set, and sticky is normally used on world writable directories, that need world execute (actually world directory traversal, but that is represented by the x bit).

----------

## rretz

can it be more clear:wink:

NO, thx a great deal:lol:

----------

