Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux directory permission s

My website runs on a third party server, and I encountered directories with the following permissions:

folder1 drwsr-s---
folder2 drwxr-s---
folder3 drwxr-x---

I'm familiar with the d, the r, the w, the x (for folders), and the -. While editing (in Filezilla), it seems all of these are equal to chmod 750.

man chmod tells me that s stands for "set user or group ID on execution". What does that mean? And how come it maps onto the same chmod code? Should I worry about this on the server?

like image 789
MrMartin Avatar asked Apr 19 '26 15:04

MrMartin


1 Answers

The 's' bits are referred to as the "setuid" and "setgid" bits. What it does depends on the file type.

On a directory, as in your example, these bits set the default user or group for all files created in the directory.

EG, if you have a directory owned by foo:foo, with the setuid and setgid bits set, then all files created in that directory will be owned by foo:foo, regardless of who creates them.

In your example, the "setgid" bit is set for each directory. This means that for every file created in these directories, the owner will be the user who created the file, but the group will be set to match the directory's group, rather than the user's main group.

like image 190
Swiss Avatar answered Apr 21 '26 12:04

Swiss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!