Linux下chmod赋权详解
2017-12-04
1877
简介:
Linux文件有rwx即读、写、执行三种权限管理文件权限 文件访问权限:rwxrwxrwx (777) 权限数值化后:(7)(7)(7) r 读 -4 允许用户打开、浏览文件内容 w 写 -2 允许用户打开、编辑文件 x 执行 -1 允许用户执行新创建文件默认权限为rw-r--r-- (644) .
Linux文件有rwx即读、写、执行三种权限管理文件权限 文件访问权限:rwxrwxrwx (777) 权限数值化后:(7)(7)(7) r 读 -4 允许用户打开、浏览文件内容 w 写 -2 允许用户打开、编辑文件 x 执行 -1 允许用户执行新创建文件默认权限为rw-r--r-- (644) 默认文件权限根据umask值设置(默认为022) 新文件权限为rw-r-r(644) 666 – 022 = rw-r--r--新创建目录默认权限为rwxr-xr-x (755) 默认目录权限根据umask值设置(默认为022) 新目录权限为rwxr-xr-x 777 - 022 = rwxr-xr-xumask修改权限:chmod 添加、删除文件或目录状态 chmod u+x chmod u=rwx,g=rw,o=r chmod 764 chmod o-r hello.txt
chmod a+x test 给所有用户other赋予执行权限(生产服务器不推荐给所有用户都赋予执行权限)chmod u+x test 给当前用户other赋予执行权限chmod g+x test 给同组用户other赋予执行权限chmod o+x test 给其他用户other赋予执行权限chmod +x test 默认是给所有用户赋予执行权限chmod -x test 默认是给所有用户取消执行权限去掉相应权限用-,例如:chmod a-x test 给所有用户other去除执行权限指定权限用=,例如:chmod u=rwx test 指定当前用户拥有读写执行权限实例:[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg[root@RHEL7x64 ~]# touch test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rw-r--r--. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod u+x test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr--r--. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod o+x test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr--r-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod g+x test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod a-x test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rw-r--r--. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod a+x test[root@RHEL7x64 ~]# ll总用量 4-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# [root@RHEL7x64 ~]# ll总用量 8-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rw-r--r--. 1 root root 1915 7月 2 16:07 memtop.sh-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod +x memtop.sh[root@RHEL7x64 ~]# ll总用量 8-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr-xr-x. 1 root root 1915 7月 2 16:07 memtop.sh-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod -x memtop.sh[root@RHEL7x64 ~]# ll总用量 8-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rw-r--r--. 1 root root 1915 7月 2 16:07 memtop.sh-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]# chmod u+x memtop.sh[root@RHEL7x64 ~]# ll总用量 8-rw-------. 1 root root 1209 6月 24 16:15 anaconda-ks.cfg-rwxr--r--. 1 root root 1915 7月 2 16:07 memtop.sh-rwxr-xr-x. 1 root root 0 6月 27 17:44 test[root@RHEL7x64 ~]#
本文转自ICT时空dbasdk的博客,原文链接:Linux下chmod赋权详解 ,如需转载请自行联系原博主。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。