suid sgid
2016-06-18 14:36
501 查看
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权限
[root@yami test]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# chmod 2755 .
[root@yami test]# ;s -ld
-bash: syntax error near unexpected token `;'
[root@yami test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami 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
[scott@yami test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
touch: cannot touch `scott.sgid': Permission denied
[scott@yami test]$ touch
touch: missing file operand
Try `touch --help' for more information.
[scott@yami test]$ touch scott
touch: cannot touch `scott': Permission denied
[scott@yami test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ exit
logout
[root@yami test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# chmod g+w .
[root@yami test]# ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami test]$ ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
touch: cannot touch `scott.sgid': Permission denied
[scott@yami test]$ touch scott
touch: cannot touch `scott': Permission denied
[scott@yami test]$ exit
logout
[root@yami test]# chmod g-w .
[root@yami test]# chmod 0+w .
chmod: invalid mode: `0+w'
Try `chmod --help' for more information.
[root@yami test]# chmod o+w .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami test]$ ls -ld
drwxr-srwx 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
[scott@yami 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
=====
[root@yami suid]# chmod 1777 .
[root@yami suid]# ls -ld
drwsrwsrwt 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 777 .
[root@yami suid]# ls -ld
drwsrwsrwx 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 2755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 644 .
[root@yami suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 0644 .
[root@yami suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 4755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[root@yami suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[root@yami suid]# chmod 755 ../suid/
[root@yami suid]#
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# ls -ld /test/
drwxr-srwx 2 root root 4096 Jun 18 14:10 /test/
[root@yami suid]# chmod 755 /test
[root@yami suid]# ls -ld /test/
drwxr-sr-x 2 root root 4096 Jun 18 14:10 /test/
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# ls -l
total 4
-rwxr--r-- 1 root root 8 Jun 18 14:31 file
[root@yami suid]# rm file
rm: remove regular file `file'? y
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod 755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod u-s .
[root@yami suid]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod g-s .
[root@yami suid]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 18 14:42 .
以上为:想要删除掉setuid,setgid权限,用chmod 755 .发现不好使
用chmod ug-s .就可以,故做修改
-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权限
[root@yami test]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# chmod 2755 .
[root@yami test]# ;s -ld
-bash: syntax error near unexpected token `;'
[root@yami test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami 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
[scott@yami test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
touch: cannot touch `scott.sgid': Permission denied
[scott@yami test]$ touch
touch: missing file operand
Try `touch --help' for more information.
[scott@yami test]$ touch scott
touch: cannot touch `scott': Permission denied
[scott@yami test]$ ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ exit
logout
[root@yami test]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# chmod g+w .
[root@yami test]# ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami test]$ ls -ld
drwxrwsr-x 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
touch: cannot touch `scott.sgid': Permission denied
[scott@yami test]$ touch scott
touch: cannot touch `scott': Permission denied
[scott@yami test]$ exit
logout
[root@yami test]# chmod g-w .
[root@yami test]# chmod 0+w .
chmod: invalid mode: `0+w'
Try `chmod --help' for more information.
[root@yami test]# chmod o+w .
[root@yami test]# su - scott
[scott@yami ~]$ cd /test/
[scott@yami test]$ ls -ld
drwxr-srwx 2 root root 4096 Jun 17 18:27 .
[scott@yami test]$ touch scott.sgid
[scott@yami 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
=====
[root@yami suid]# chmod 1777 .
[root@yami suid]# ls -ld
drwsrwsrwt 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 777 .
[root@yami suid]# ls -ld
drwsrwsrwx 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 2755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 644 .
[root@yami suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 0644 .
[root@yami suid]# ls -ld
drwSr-Sr-- 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 4755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[root@yami suid]# chmod 755 ../s
sbin/ selinux/ srv/ suid/ sys/
[root@yami suid]# chmod 755 ../suid/
[root@yami suid]#
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# ls -ld /test/
drwxr-srwx 2 root root 4096 Jun 18 14:10 /test/
[root@yami suid]# chmod 755 /test
[root@yami suid]# ls -ld /test/
drwxr-sr-x 2 root root 4096 Jun 18 14:10 /test/
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:17 .
[root@yami suid]# ls -l
total 4
-rwxr--r-- 1 root root 8 Jun 18 14:31 file
[root@yami suid]# rm file
rm: remove regular file `file'? y
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod 755 .
[root@yami suid]# ls -ld
drwsr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod u-s .
[root@yami suid]# ls -ld
drwxr-sr-x 2 root root 4096 Jun 18 14:42 .
[root@yami suid]# chmod g-s .
[root@yami suid]# ls -ld
drwxr-xr-x 2 root root 4096 Jun 18 14:42 .
以上为:想要删除掉setuid,setgid权限,用chmod 755 .发现不好使
用chmod ug-s .就可以,故做修改
相关文章推荐
- webpack知识,在html里通过webpack使用commonJS规范,可以require各种包
- require(),include(),require_once()和include_once()之间的区别
- 项目总结3 类似网易云音乐导航栏指示器(个性推荐、歌单等)的简单实现(一)
- dz query
- 357. Count Numbers with Unique Digits
- EasyUI datagrid 明细表格中编辑框 事件绑定 及灵活计算 可根据此思路 扩展其他
- Qualcomm Symphony System Manager SDK使用举例
- QT UI更改编译后,输出无变化 解决
- UITableViewcell 样式的自定义
- iOS中关于NavigationController中UIStatusBar黑白切换以及preferredStatusBarStyle一直不执行的问题
- Bluetooth
- iOS中管理剪切板的UIPasteboard粘贴板类用法详解
- HackerRank "Square Subsequences" !!!
- mybatis_user_guide(2)mybatis3.4.0快速入门
- Repeated DNA Sequences
- cocoa touch——UIControl——state,highlighted,enabled,selected
- cocoa touch——UIImageView
- cocoa touch——UILabel
- java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
- leecode_357 Count Numbers with Unique Digits