linux机关命令,Linux四个常用的指挥机关处理具体的解释

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

权限

对于文件

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值