chmod 赋权所有_Linux下chmod赋权详解-阿里云开发者社区

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-x777 - 022 = rwxr-xr-xumask修改权限:chmod添加、删除文件或目录状态chmod u+xchmod u=rwx,g=rw,o=r chmod 764chmod 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赋权详解 ,如需转载请自行联系原博主。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值