| ---- 1 test1 test1 17 Jul 14 22:11 test1.txt
而如下操作则可以让除了test1有读写的权限外其他人没有读写test1.txt的权限(root除外),先用test2 登录系统后执行以下命令: [test2@mail test2]# cd /fs1 [test2@mail fs1]# cat test1.txt cat : test1.txt Permission denied
接着用test1登录系统,执行如下命令: [test1@mail fs1]# setfacl -m u:test2:rw test1.txt
这样就修改权限允许test2 有这个文件的读写权限。再看一下它的文件属性的变化: [test1@mail fs1]# ll -rw-rw-r--+ 1 test1 test1 10 Feb 16 13:52 test1.txt
会看到后面多了一个“+”,表示这个文件使用ACL的属性设置,再用命令getfacl来看ACL的文件属性设置: [test1@mail fs1]# getfacl test1.txt # file: test1.txt # owner: test1 # group: test1 user::rw- user:test2:rw- group::rw- mask::rw- other::r--
可以看到 test2 有权限读写这个文件。
我们再用test2登录系统执行以下命令,看看发生了什么? [test2@mail test2]# cd /fs1 [test2@mail fs1]# cat test1.txt Create by test1
原来test2可以读取test1.txt文件了。 [test2@mail fs1]# echo "Modify by test2" >> test1.txt [test2@mail fs1]# cat test1.txt Create by test1 Modify by test2
现在test2也可以修改test1.txt文件了。
接着用test3 登录系统: [test3@mail test3]# cd /fs1 [test3@mail fs1]# cat test1.txt cat : test1.txt Permission denied
嘿嘿,除了test1、test2外没有其他用户有读写test1.txt的权限(root 除外)。
看着虽然有点晕,其实命令就是这么一两条,主要是把各种情况给大家讲清楚,这样,大家在使用Linux中才会发现,比起脆弱的Windows的权限防护,Linux实在是做得相当不错! 上一页 [1] [2] |