转自:http://keren.blog.51cto.com/720558/144908 ,个人认为这篇博文较容易理解,不错。
gaolu@gaolu-desktop:~$ cd /etc
gaolu@gaolu-desktop:/etc$ ls -l shadow
-rw-r----- 1 root shadow 978 2009-02-22 21:25 shadow
gaolu@gaolu-desktop:/etc$
gaolu@gaolu-desktop:/usr/bin$ ls -l passwd
-rwsr-xr-x 1 root root 32988 2008-06-10 02:10 passwd
gaolu@gaolu-desktop:/usr/bin$
gaolu@gaolu-desktop:/usr/bin$
gaolu@gaolu-desktop:~$ chmod u+s uid //用户主增加权限setuid
gaolu@gaolu-desktop:~$ ls -l uid
-rwsr-xr-x 1 gaolu gaolu 9118 2009-03-08 22:26 uid
gaolu@gaolu-desktop:~$
gaolu@gaolu-desktop:~$ ./uid
Current process UID: 1000
Current process EUID: 1000
gaolu@gaolu-desktop:~$
gaolu@gaolu-desktop:~$ su //切换到root用户
Password:
root@gaolu-desktop:/home/gaolu# ls -l uid
-rwsr-xr-x 1 gaolu gaolu 9118 2009-03-08 22:26 uid
root@gaolu-desktop:/home/gaolu# ./uid
Current process UID: 0
Current process EUID: 1000 //有效用户ID为1000
root@gaolu-desktop:/home/gaolu#
root@gaolu-desktop:/home/gaolu#