c=character device, b=block device, d=door, s = socket
linux下,文件夹的r——可列文件夹,w——可写/删/改名,x——可进入訪问;
文件r——可读。w——可写/删/改名,x——运行
权限的组合可汇合成一个数字: rwx = 4+2+1 = 7
因此:-rwxrwxrwx = 777, -rw-rw-rw=666, -rwx-r-x-r-x=755一般通过chmod的參数进行设置:
chmod 777 /dir/file 设置文件为读写运行 chmod -x /dir/file 删除文件uga的可运行 chmod ga-w /dir/file 删除文件ga的可写权限 chmod u=rx /dir/file 重设置文件u为读和运行 chmod +x /dir/file 添加文件uga为可运行事实上这个结果是通过 mask = rwx - 文件权限
如设置文件为0755权限,那么mask值则需为0022,即:0755=0777-0022
fstab实例:
<file system> <mount point> <type> <options> <dump> <pass> /dev/hda1 /media/win ntfs defaults,utf8,umask=111 0 0当中:umask=111==>(777-111)=666=rw-rw-rw, 即文件拥有读写权限
能够又一次设计更更严格的权限关系:
dmask=022,fmask=133 即:f=755=rwxr-xr-x, d=644=rw-r--r--
注意:事实上umask可理解为关闭某些权限。能够使用umask命令改变一个文件的权限: umask 查看当前文件夹的权限mask umask <mask> 设置当前当文件夹设置了sgid后。其它人要是有r/x/w权限时,其它人创建的子文件夹的组为当前拥有的组
chmod 757 dir (owner) chmod g+s dir ==> drwxr-srwx (ower) mkdir dir/newidr (user) (即当user创建子文件夹时。它的组是owner,它的拥有者则是user) (sgid经常使用于文件夹上)当文件夹设置了sticky后,防止别人删除文件夹的资料
chmod 757 dir (owner组) chmod o+t dir ==> drwxr-srwt (owner) rm -r dir (user) ==> error (user无法删除。尽管开放了删除权限。但还是仅仅有owner可删除)样例:
chmod u=rwxs,o=rx file chmod g+s,o=wrx test/ chmod o=rwxt test/ chmod 1775 test/0755也就是755, 而1755前面的1则与suid/sgid/sticky相关。看下表:
(能够理解为suid=4,sgid=2,sticky=1) suid sgid sticky 模式数字 on on on 7 on on off 6 on off on 5 on off off 4 off on on 3 off on off 2 off off on 1 off off off 0http://www.itlearner.com/article/4594
http://askubuntu.com/questions/429848/dmask-and-fmask-mount-options
http://blog.sina.com.cn/s/blog_70545bad0100xdnp.html
转载于:https://www.cnblogs.com/bhlsheji/p/5327718.html