linux中如何让普通用户访问其他用户的目录

目前有一个test1分组,分组下test1用户可访问/home/test1目录,现有一个普通用户test2需要访问该目录中的日志文件,

此时test2用户想要访问该目录可有一下方法实现:

将用户加入到要访问的分支中,usermod -G test1 test2,并为该目录设置分组下可访问 chmod -R 774 /home/test1/

整个测试过程如下:

[root@test-server-1 home]# useradd test1
[root@test-server-1 home]# useradd test2
[root@test-server-1 home]# passwd test1
Changing password for user test1.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@test-server-1 home]# passwd test2
Changing password for user test2.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@test-server-1 home]# use test2
-bash: use: command not found
[root@test-server-1 home]# su test2
[test2@test-server-1 home]$ cd test1
bash: cd: test1: Permission denied #此时访问被禁止
[test2@test-server-1 home]$ exit
[root@test-server-1 home]# usermod -G test1 test2
[root@test-server-1 home]# chmod -R 774 /home/test1
[root@test-server-1 home]# su test2
[test2@test-server-1 home]$ cd test1
[test2@test-server-1 test1]$ ll  #此时访问通过,方法可行
total 0
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值