歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux系統對訪問控制(ACL)權限的實現

Linux系統對訪問控制(ACL)權限的實現

日期:2017/2/28 14:37:08   编辑:Linux教程

Linux系統對訪問控制(ACL)權限的實現

1.對分區添加一個ACL訪問控制的權限和增加用戶
[root@localhost ~]# mount -o remount,acl /dev/md0 /mnt/sdb
[root@localhost ~]# useradd user1
[root@localhost ~]# useradd user2

2.關於用戶對目錄的權限授權
[root@localhost ~]# setfacl -m u:user1:rwx /mnt/sdb
[root@localhost ~]# setfacl -m u:user2:rx /mnt/sdb

3.測試是否生效
[root@localhost ~]# su - user1 --連接user1用戶
[user1@localhost ~]$ cd/mnt/sdb
[user1@localhost sdb]$ mkdirqw --user1用戶可以寫入文件
[user1@localhost sdb]$ touch1.txt
[user1@localhost sdb]$ exit
logout
[root@localhost ~]# su - user2 --連接user2用戶
[user2@localhost ~]$ cd/mnt/sdb
[user2@localhost sdb]$ mkdiras --不能創建目錄
mkdir: cannot create directory `as': Permission denied
[user2@localhost sdb]$ touch2.txt --不能寫入文件
touch: cannot touch`2.txt': Permission denied
[user2@localhost sdb]$

4.查看文件是否的控制權限和取消控制權限
[user2@localhost sdb]$ getfacl 1.txt --查看文件權限
# file: 1.txt
# owner: user1
# group: user1
user::rw-
group::rw-
other::r--
[user2@localhost sdb]$ getfacl qw --查看目錄權限
# file: qw
# owner: user1
# group: user1
user::rwx
group::rwx
other::r-x
[root@localhost ~]# setfacl -x u:user1 /mnt/sdb --用-x取消權限
[root@localhost ~]# getfacl /mnt/sdb --查看取消之後的權限
getfacl: Removing leading '/'from absolute path names
# file: mnt/sdb
# owner: root
# group: root
user::rwx
user:user2:r-x
group::r-x
mask::r-x
other::rwx
[root@localhost ~]#

Linux實現Cisco風格ACL之空想 http://www.linuxidc.com/Linux/2013-05/84669.htm

Linux ACL權限規劃:getfacl,setfacl使用 http://www.linuxidc.com/Linux/2013-07/88049.htm

Copyright © Linux教程網 All Rights Reserved