目录权限问题

改变权限

读取(r)、写入(w)和执行(x)

可以使用 chmod (change mode) 命令来改变文件或目录的访问权限,权限可以使用符号或数字来表示。

符号 说明
+ 为文件或目录增加权限
- 删除文件或目录的权限
= 设置指定的权限
例子:

$ls -l testfile
-rwxrwxr--  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod o+wx testfile
$ls -l testfile
-rwxrwxrwx  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod u-x testfile
$ls -l testfile
-rw-rwxrwx  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod g=rx testfile
$ls -l testfile
-rw-r-xrwx  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod g=rx testfile
$ls -l testfile
-rw-r-xrwx  1 amrood   users 1024  Nov 2 00:10  testfile

使用数字表示权限:
数字 说明 权限
0 没有任何权限 —
1 执行权限 –x
2 写入权限 -w-
3 执行权限和写入权限:1 (执行) + 2 (写入) = 3 -wx
4 读取权限 r–
5 读取和执行权限:4 (读取) + 1 (执行) = 5 r-x
6 读取和写入权限:4 (读取) + 2 (写入) = 6 rw-
7 所有权限: 4 (读取) + 2 (写入) + 1 (执行) = 7 rwx

$ls -l testfile
-rwxrwxr--  1 amrood   users 1024  Nov 2 00:10  testfile
$ chmod 755 testfile
$ls -l testfile
-rwxr-xr-x  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod 743 testfile
$ls -l testfile
-rwxr---wx  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod 043 testfile
$ls -l testfile
----r---wx  1 amrood   users 1024  Nov 2 00:10  testfile
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值