I know what it means for a file to have suid permission. It means when other users have execute permission for it, they execute as the owner of the file. But what does it imply when a folder has suid permission? I did some testing and it seems nothing special for the folder. Could anyone help to plain a little? Thanks.
I'm using Oracle Linux 7.6.
root:[~]# cat /etc/*release*
Oracle Linux Server release 7.6
NAME="Oracle Linux Server"
VERSION="7.6"
ID="ol"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.6"
PRETTY_NAME="Oracle Linux Server 7.6"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:6:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.6
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.6
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Oracle Linux Server release 7.6
cpe:/o:oracle:linux:7:6:server
root:[~]#
Below is my testing on a freshly installed server.
root:[~]# pwd
/root
root:[~]# ls -lad /root
dr-xr-x---. 9 root root 4096 Aug 16 22:07 /root
root:[~]# mkdir test
root:[~]# ls -lad test
drwxr-xr-x. 2 root root 4096 Aug 16 22:07 test
root:[~]#
root:[~]# useradd a
root:[~]# passwd a
Changing password for user a.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
root:[~]# chmod u+s test
root:[~]#
root:[~]# su - a
[a@localhost ~]$ cd /root/test
-bash: cd: /root/test: Permission denied
[a@localhost ~]$ cd /root
-bash: cd: /root: Permission denied
[a@localhost ~]$ logout
root:[~]#
root:[~]# ls -lad /root
dr-xr-x---. 10 root root 4096 Aug 16 22:07 /root
root:[~]# chmod o+x /root
root:[~]#
root:[~]# su - a
Last login: Fri Aug 16 22:08:54 CST 2019 on pts/0
[a@localhost ~]$ cd /root/test
[a@localhost test]$
[a@localhost test]$ pwd
/root/test
[a@localhost test]$ ls -la .
total 8
drwsr-xr-x. 2 root root 4096 Aug 16 22:07 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
[a@localhost test]$ touch file1
touch: cannot touch ‘file1’: Permission denied
[a@localhost test]$ logout
root:[~]#
root:[~]# chmod o+w test/
root:[~]#
root:[~]# su - a
Last login: Fri Aug 16 22:09:31 CST 2019 on pts/0
[a@localhost ~]$
[a@localhost ~]$ cd /root/test
[a@localhost test]$ touch file1
[a@localhost test]$ ls -la
total 8
drwsr-xrwx. 2 root root 4096 Aug 16 22:11 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
-rw-rw-r--. 1 a a 0 Aug 16 22:11 file1
[a@localhost test]$ mkdir folder1
[a@localhost test]$ ls -la
total 12
drwsr-xrwx. 3 root root 4096 Aug 16 22:11 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
-rw-rw-r--. 1 a a 0 Aug 16 22:11 file1
drwxrwxr-x. 2 a a 4096 Aug 16 22:11 folder1
[a@localhost test]$
As you can see, it seems the files and folders the user a
created in /root/test
didn't inherit the owner and group of it. The owner and group is a
and not root
. Are there any problems with my testing? I'm new in Linux.