目前有一个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