zoukankan      html  css  js  c++  java
  • linux权限管理之进程掩码

    进程掩码 mask umask

    ========================================================

    文件权限管理之: 进程umask
    进程 新建文件、目录的默认权限会受到umask的影响,umask表示要减掉的权限

    shell (vim,touch) =======umask======> 新文件或目录权限
    vsftpd =======umask======> 新文件或目录权限
    samba =======umask======> 新文件或目录权限
    useradd =======umask======> 用户HOME

    示例1: 在shell进程中创建文件
    [root@localhost ~]# umask //查看当前用户的umask权限
    0022
    [root@localhost ~]# touch file800
    [root@localhost ~]# mkdir dir800
    [root@localhost ~]# ll -d dir800 file800
    drwxr-xr-x. 2 root root 4096 3月 11 19:40 dir800
    -rw-r--r--. 1 root root 0 3月 11 19:40 file800

    示例2:修改shell umask值(临时)
    [root@localhost ~]# umask 000
    [root@localhost ~]# mkdir dir900
    [root@localhost ~]# touch file900
    [root@localhost ~]# ll -d dir900 file900
    drwxrwxrwx. 2 root root 4096 3月 11 19:44 dir900
    -rw-rw-rw-. 1 root root 0 3月 11 19:44 file900

    示例3:修改shell umask值(永久)
    [root@localhost ~]# vim /etc/profile
    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
    else
    umask 022
    fi
    [root@localhost ~]# source /etc/profile //立即在当前shell中生效


    示例4:通过umask决定新建用户HOME目录的权限
    [root@localhost ~]# vim /etc/login.defs
    UMASK 077
    [root@localhost ~]# useradd gougou
    [root@localhost ~]# ll -d /home/gougou/
    drwx------. 4 gougou gougou 4096 3月 11 19:50 /home/gougou/

    [root@localhost ~]# vim /etc/login.defs
    UMASK 000
    [root@localhost ~]# useradd yangyang
    [root@localhost ~]# ll -d /home/yangyang/
    drwxrwxrwx. 4 yangyang yangyang 4096 3月 11 19:53 /home/yangyang/


    示例5:例如vsftpd进程 /etc/vsftpd/vsftpd.conf 【了解】
    anon_umask=007
    local_umask=000








  • 相关阅读:
    Anoconda管理Python版本 | Python
    VSCode用以Python开发的配置 | VSCode
    不联网的情况下安装python环境 | Python(转)
    批量按要求修改文件名
    [OpenLayers] 控件系列之SelectFeature同时支持hover与click
    python使用suds调用webservice接口
    【转载】eMBMS知识点汇总(概念/应用场景/工作原理/标准进程/发展现状)
    处理器分类
    3GPP Release 4G-5G 演进
    浅谈css中一个元素如何在其父元素居中显示
  • 原文地址:https://www.cnblogs.com/anttech/p/10597586.html
Copyright © 2011-2022 走看看