文件的基数为:666 
文件夹的基数为:777
chmod和chown 以前讲过的。就先不讲了
下面的内容是冒险位和强制位,网上也有说成粘着位的,具体说法不重要,大家知道是怎么回事就OK了
大家还记得怎么看用户的权限掩码吗? 
umask
 
我们以前教的是后面三位,当时没给大家说最前面那位,今天我们就学最前面那位,强制位与冒险位.
所谓的强制位和冒险位都是最最前面那个0的位置来表示,当前面那个位,24权限就叫强制位,1的权限就是冒险位,2代表的是GID4代表的是uid1代表的是sticky
下面给大家介绍gid,uid,sticky的作用
GID的作用:默认情况下,用户建立的文件属于用户当前所在的组但是设置了GID以后,表示在此目录中,任何人建立的文件,都会属于目录所属的组。注意:GID只能对目录设置
UID的作用:当一个文件设置了UID,那么所有用户执行这个文件的时候,都是以这个用户的所有者的权限来执行。
我们先来做两个实验:
建立一个目录 redhat:mkdir redhat
 
然后我们给他设置GID:chmod 2755 redhat/
 
大家发现文件的权限有什么变化吗?呵呵,那个s就是强制位的标志
我们把权限给他改回来:chmod 0755 redhat/
 
chmod g+s 文件名 用这个命令也可以给他设置GID
chmod g+s redhat/

[root@beryl ~]# cd /tmp

[root@beryl tmp]# mkdir natasha
[root@beryl tmp]# ls -ld natasha/
drwxr-xr-x 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# chmod 2755 natasha/
[root@beryl tmp]# ls -ld natasha/
drwxr-sr-x 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# chmod 0755 natasha/
[root@beryl tmp]# ls -ld natasha/
drwxr-xr-x 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# chmod 4755 natasha/
[root@beryl tmp]# ls -ld natasha/
drwsr-xr-x 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# chmod 0755 natasha/
[root@beryl tmp]# chmod 1755 natasha/
[root@beryl tmp]# ls -ld natasha/
drwxr-xr-t 2 root root 4096 Apr 15 09:05
natasha/

[root@beryl tmp]# chmod g-s natasha/
[root@beryl tmp]# ls -ld natasha/
drwxr-xr-x 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# chmod 2777 natasha/
[root@beryl tmp]# ls -ld natasha/
drwxrwsrwx 2 root root 4096 Apr 15 09:05 natasha/
[root@beryl tmp]# su - natasah
su: user natasah does not exist
[root@beryl tmp]# su - natasha
su: user natasha does not exist
[root@beryl tmp]# useradd natasha
[root@beryl tmp]# su - natasha
[natasha@beryl ~]$ cd /tmp
[natasha@beryl tmp]$ ls -ld natasha/
drwxrwsrwx 2 root root 4096 Apr 15 09:05 natasha/
[natasha@beryl tmp]$ cd natasha
[natasha@beryl natasha]$ ll
total 0
[natasha@beryl natasha]$ touch file
[natasha@beryl natasha]$ ll
total 0
-rw-rw-r-- 1 natasha root 0 Apr 15 09:42 file
让普通用户可以重启系统:

[natasha@beryl natasha]$ which reboot
/usr/bin/reboot
[natasha@beryl natasha]$ ll /usr/bin/reboot
lrwxrwxrwx 1 root root 13 Apr 12 02:09 /usr/bin/reboot -> consolehelper
[natasha@beryl natasha]$ ll /usr/bin/consolehelper
-rwxr-xr-x 1 root root 5968 Sep  8  2008 /usr/bin/consolehelper

[natasha@beryl natasha]$ su -
Password:
[root@beryl ~]# chmod u+s /usr/bin/consolehelper
[root@beryl ~]# ll /usr/bin/con
conjure            conmen             consolehelper-gtk
conman             consolehelper      convert
[root@beryl ~]# ll /usr/bin/consolehelper
-rwsr-xr-x 1 root root 5968 Sep  8  2008 /usr/bin/consolehelper
[root@beryl ~]# su - natasha
[natasha@beryl ~]$ reboot