• Linux四个常用的指挥机关处理具体的解释


    原版的Blog。转载请注明出处

    http://blog.csdn.net/hello_hwc?viewmode=contents

    权限

    对于文件
    r 可读
    w 可写
    x 可运行
    对于文件夹
    r 能够列出文件夹的内容(ls)
    w 能够在文件夹中创建和删除文件(touch/rm)
    x 能够进入文件夹(cd)


    一、chmod
    chmod用来改变权限
    经常使用的方式
    1、用ugo+rwx 或者ugo-rwx或者ugo=rwx改变权限
    这里的ugo
    u 用户
    g 用户组
    o 其它人
    比方:ug+x 就是为用户和用户组添加可运行权限
    举例:
    [root@localhost testForCsdn]# ls -l testfile 
    -rw-r----- 1 root root 0 Nov  1 22:14 testfile

    为其它人赋予读写权限
    [root@localhost testForCsdn]# chmod o=rw testfile 
    [root@localhost testForCsdn]# ls -l testfile 
    -rw-r--rw- 1 root root 0 Nov  1 22:14 testfile

    为其它人去掉写的权限
    [root@localhost testForCsdn]# chmod o-w testfile 
    [root@localhost testForCsdn]# ls -l testfile 
    -rw-r--r-- 1 root root 0 Nov  1 22:40 testfile

    为用户组加入写的权限
    [root@localhost testForCsdn]# chmod g+w testfile 
    [root@localhost testForCsdn]# ls -l testfile 
    -rw-rw-r-- 1 root root 0 Nov  1 22:40 testfile

    2、用数字的方式改变权限
    r相应4
    w相应2
    x相应1
    比方:5=4+1 那么5代表的就是可读和可运行权限
    举例
    创建一个空文件,而且查看权限,能够看到,当前权限是rw-r--r--
    也就是说:
    对说有着来说是rw- 可读可写不可运行
    对所属组来说是r-- 仅仅可写
    对其它人来说是r-- 仅仅可写
    举例
    创建一个脚本。而且赋予它全部者的可运行权限
    [root@localhost testForCsdn]# touch test.script
    [root@localhost testForCsdn]# ls -l test.script 
    -rw-r----- 1 root root 0 Nov  1 22:43 test.script
    [root@localhost testForCsdn]# chmod 744 test.script 
    [root@localhost testForCsdn]# ls -l test.script 
    -rwxr--r-- 1 root root 0 Nov  1 22:43 test.script

    二、chown
    改变全部者
    首先加入用户hwc
    [root@localhost testForCsdn]# useradd hwc
    [root@localhost testForCsdn]# chown hwc test.script 
    [root@localhost testForCsdn]# ls -l test.script 
    -rwxr--r-- 1 hwc root 0 Nov  1 22:43 test.script

    三、chgrp
    改变所属组
    首先加入用户组hwcgroup
    [root@localhost testForCsdn]# chgrp hwcgroup test.script 
    [root@localhost testForCsdn]# ls -l test.script 
    -rwxr--r-- 1 hwc hwcgroup 0 Nov  1 22:43 test.script

    四、umask
    文件和文件夹创建的默认权限
    查看默认权限
    [root@localhost ~]# umask
    0022
    解释下,这里的第一个0是特殊权限位。一般不作考虑
    022是用户权限位,这里的是掩码值
    对于文件
    即实际的权限应该是完整的权限777-022-111 = 644
    就是rw-r--r--
    改变缺省的权限值
    [root@localhost ~]# umask 027
    [root@localhost ~]# umask
    0027
    


    版权声明:本文博主原创文章,如需转载请注明出处

  • 相关阅读:
    进程通信方式-管道pipe
    进程间通信
    信号的发送与处理
    信号应用于事件通知
    信号的屏蔽,信号集
    信号的发送kill,raise,alarm,setitimer,abort,sigqueue
    信号处理函数的返回sigsetjmp/siglongjmp
    POJ 1562 Oil Deposits
    HDU 1016 Prime Ring Problem
    HDU 1010 Tempter of the Bone
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4869225.html
Copyright © 2020-2023  润新知