sgid&suid&sticky bit

[root@station home]# ll -d admins/
drwxrwx---. 2 root adminuser 1024 Apr  9 16:19 admins/
[root@station home]# chmod 1770 admins/
[root@station home]# ll -d admins/
drwxrwx--T. 2 root adminuser 1024 Apr  9 16:19 admins/
[root@station home]# chmod -t admins/
[root@station home]# chmod 2770 admins/
[root@station home]# ll -d admins/
drwxrws---. 2 root adminuser 1024 Apr  9 16:19 admins/
[root@station home]# chmod -s admins/
[root@station home]# ll -d admins/
drwxrwx---. 2 root adminuser 1024 Apr  9 16:19 admins/
[root@station home]# chmod 4770 admins/
[root@station home]# ll -d admins/
drwsrwx---. 2 root adminuser 1024 Apr  9 16:19 admins/
[root@station home]# chmod -s admins/
[root@station home]# chmod 7770 admins/
drwsrws--T. 2 root adminuser 1024 Apr  9 16:19 admins/

chmod #ugo file
# = 1: sticky bit
# = 2: set group id (sgid)
# = 4: set user id (suid)

You can set or clear the bits with symbolic modes like u+s and g-s, and you  can  set (but not clear) the bits with a numeric mode.


sticky bit:
For directories, it  prevents unprivileged users from removing or renaming a file in the directory unless they own the file or the directory; this is called the restricted deletion flag for the directory, and is commonly found on world-writable  directories  like  /tmp.

set group id:
For directories, file created under the directory will have the same group as father directory.

set user id:
For files, user can run the program with owner's privilege.

REF:

man chmod



posted @ 2012-04-09 21:34  生活不是用来挥霍的  阅读(259)  评论(0编辑  收藏  举报