[root@redhat root]# which ls 查看ls所在的路径及命名信息 alias ls='ls --color=tty' /bin/ls [root@redhat root]# which ping 查看ping所在的路径信息 /bin/ping [root@redhat root]# ls -l /bin/ping -rwsr-xr-x 1 root root 28628 2003-01-25 /bin/ping 说明其它用户执行ping 时,是用root的权限使用的,因为ping设置了UID,并且拥有者是root 如果删除ping对root的UID后: [luowei@redhat luowei]$ ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.803 ms
--- 127.0.0.1 ping statistics --- 7 packets transmitted, 7 received, 0% packet loss, time 6008ms rtt min/avg/max/mdev = 0.053/0.170/0.803/0.259 ms [luowei@redhat luowei]$ su - Password: [root@redhat root]# chmod u-s /bin/ping 删除ping文件的UID [root@redhat root]# ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.856 ms
--- 127.0.0.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1006ms rtt min/avg/max/mdev = 0.098/0.477/0.856/0.379 ms [root@redhat root]# su - luowei [luowei@redhat luowei]$ ping 127.0.0.1 这将没有权限ping了 ping: icmp open socket: Operation not permitted [luowei@redhat luowei]$ su - Password: [root@redhat root]# chmod u+s /bin/ping 添加ping文件对root的UID [root@redhat root]# su - luowei [luowei@redhat luowei]$ ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.058 ms
注意:uid只能对文件设定,gid既可以在文件上设定也可以在目录上设定,在目录上可以设定gid与冒险位(sticky),冒险位(sticky)只能设定在目录上。
|