创建文件和目录时的默认权限umask

1.概念

linux系统中文件的默认权限是在/etc/bashrc文件中记载着:
 # By default, we want umask to get set. This sets it for non-login shell.
    # Current threshold for system reserved uid/gids is 200
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
       umask 002    //一般用户默认权限
    else
       umask 022   //root用户默认权限
    fi


    # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars

可以使用umask命令查看默认权限
[root@zhangyong zy]# umask -S
u=rwx,g=rx,o=rx

linux系统规定文件的默认最大权限是666,目录的默认最大权限是777,那么umask=022 需要反过来看就是755(u=rwx,g=rx,o=rx),所以对应权限:
1.目录:022->755(u=rwx,g=rx,o=rx)
2.文件:022->644(u=rw,g=rx,o=rx)

2.修改默认权限


[root@zhangyong zy]# umask
0022
[root@zhangyong zy]# umask 002
[root@zhangyong zy]# umask
0002
[root@zhangyong zy]#



  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值