setuid:跟文件所有者一样,得到相同权限。sudo为权限下放,su - user为切换用户
-rwsr-xr-x root root /usr/bin/passwd:s小写说明有x权限(大写则没有x权限),其他所有的人用有跟root用户一样权限可操作/usr/bin/passwd文件
chmod 4755 /xx 可让文件获取该权限
chmod 755 /xx 取消文件该权限
suid典型列子/usr/bin/passwd,都能使用这个命令: passwd xx
setgid:用于目录中,多用户共享一个权限创建目录
粘贴位一般也是用于目录
使任何人在该目录下创建的文件都属于该用户组
chmod 2644 /dir 获取gid权限
[[email protected] test]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]# chmod 2755 .
[[email protected] test]# ;s -ld
-bash: syntax error near unexpected token `;‘
[[email protected] test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]# su - scott
[[email protected] ~]$ cd /test/
[[email protected] test]$ ls -l
total 16
-rw-r--r-- 1 root root 0 Jun 17 18:27 a.out
-rw-r--r-- 1 root root 164 Jun 17 04:32 hosts.txt
-rw-r--r-- 1 root root 39 Jun 17 04:32 network.txt
-rw-r--r-- 1 root root 1694 Jun 17 04:32 passwd.txt
-rw-r--r-- 1 root root 16 Jun 17 18:14 test.txt
[[email protected] test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[[email protected]mi test]$ touch scott.sgid
touch: cannot touch `scott.sgid‘: Permission denied
[[email protected] test]$ touch
touch: missing file operand
Try `touch --help‘ for more information.
[[email protected] test]$ touch scott
touch: cannot touch `scott‘: Permission denied
[[email protected] test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]$ exit
logout
[[email protected] test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]# chmod g+w .
[[email protected] test]# ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]# su - scott
[[email protected] ~]$ cd /test/
[[email protected] test]$ ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[[email protected] test]$ touch scott.sgid
touch: cannot touch `scott.sgid‘: Permission denied
[[email protected] test]$ touch scott
touch: cannot touch `scott‘: Permission denied
[[email protected] test]$ exit
logout
[[email protected] test]# chmod g-w .
[[email protected] test]# chmod 0+w .
chmod: invalid mode: `0+w‘
Try `chmod --help‘ for more information.
[[email protected] test]# chmod o+w .
[[email protected] test]# su - scott
[[email protected] ~]$ cd /test/
[[email protected] test]$ ls -ld
drwxr-srwx 2 root root 4096 Jun 17 18:27 .
[[email protected] test]$ touch scott.sgid
[[email protected] test]$ ls -l
total 16
-rw-r--r-- 1 root root 0 Jun 17 18:27 a.out
-rw-r--r-- 1 root root 164 Jun 17 04:32 hosts.txt
-rw-r--r-- 1 root root 39 Jun 17 04:32 network.txt
-rw-r--r-- 1 root root 1694 Jun 17 04:32 passwd.txt
-rw-rw-r-- 1 scott root 0 Jun 18 14:10 scott.sgid
-rw-r--r-- 1 root root 16 Jun 17 18:14 test.txt
=====
[[email protected] suid]# chmod 1777 .
[[email protected] suid]# ls -ld
drwsrwsrwt 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 777 .
[[email protected] suid]# ls -ld
drwsrwsrwx 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 2755 .
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 644 .
[[email protected] suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 0644 .
[[email protected] suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 4755 .
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[[email protected] suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[[email protected] suid]# chmod 755 ../suid/
[[email protected] suid]#
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# ls -ld /test/
drwxr-srwx 2 root root 4096 Jun 18 14:10 /test/
[[email protected] suid]# chmod 755 /test
[[email protected] suid]# ls -ld /test/
drwxr-sr-x 2 root root 4096 Jun 18 14:10 /test/
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[[email protected] suid]# ls -l
total 4
-rwxr--r-- 1 root root 8 Jun 18 14:31 file
[[email protected] suid]# rm file
rm: remove regular file `file‘? y
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[[email protected] suid]# chmod 755 .
[[email protected] suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[[email protected] suid]# chmod u-s .
[[email protected] suid]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 18 14:42 .
[[email protected] suid]# chmod g-s .
[[email protected] suid]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 18 14:42 .
以上为:想要删除掉setuid,setgid权限,用chmod 755 .发现不好使
用chmod ug-s .就可以,故做修改