使用setfacl&getfacl管理文件权限

##保证分区挂载的时候添加了acl参数
[alex@localhost /home/robin]$cat /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Sun Jun 14 21:39:50 2009
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or vol_id(8) for more info
#
UUID=dbb7aa5a-3e19-47da-800f-4e327012a7cd     /var                ext4     defaults          1 0
UUID=87a9a290-823b-48ce-aafb-8c5e97f5156d      /tmp               ext4     defaults          1 0
UUID=33d2fbd8-4f4e-4a19-862e-b50754eff834       /usr                ext4     defaults          1 0
UUID=f9bce48a-7fd0-4837-a28c-89dc2b457b83      /boot              ext3     defaults          1 0
UUID=07f94ab8-88bd-484b-8faf-f7ef571ad9e2        /home            ext4     defaults,acl    1 0
UUID=8fd91fec-b5c0-401e-8cda-0b86bdc4e009       /                     ext4     defaults          1 0
UUID=c4485dae-0f90-469c-9c8d-5b8c9e840788      /opt                ext4     defaults          1 0
UUID=bc758b3d-a2d7-40fd-b47d-823289d75bde     /usr/local        ext4     defaults          1 0
UUID=1d043a8a-ed70-4daf-b02f-f5ddd1ae5223      /mnt/hdisk3    ext3      defaults          1 0
UUID=798ca4df-9ea1-471d-9152-0edc52d71d8c     /mnt/hdisk2    ext3      defaults          1 0
UUID=8aaf0822-5256-4729-b4fe-93832733ad20     /mnt/hdisk1     ext3     defaults          1 0
UUID=280cdcd9-f326-4232-b2c9-e364aa946bd8     swap               swap    defaults          0 0
tmpfs                                                                          /dev/shm        tmpfs    defaults          0 0
devpts                                                                         /dev/pts          devpts  defaults          0 0
sysfs                                                                           /sys                 sysfs     defaults          0 0
proc                                                                            /proc              proc      defaults          0 0
UUID=f42cf634-e0c8-4c6f-8ece-b6258cdf2513        /mnt/data1     ext3      defaults          1 0
UUID=9c48004a-c027-4e66-b373-325fcd5ab69e     /mnt/data2     ext3      defaults          1 0
##检查robin目录的原始属性
[alex@localhost /home]$getfacl robin/
# file: robin/
# owner: robin
# group: robin
user::rwx
group::—
other::—
##使用alex账户cd到robin的目录下时被禁止
[alex@localhost /home]$cd robin/
bash: cd: robin/: Permission denied
##使用robin账户修改robin的权限,是alex账户能访问robin目录
[alex@localhost /home]$su robin
Password: 
[robin@localhost /home]$setfacl -m u:alex:rx /home/robin
[robin@localhost /home]$getfacl robin/
# file: robin/
# owner: robin
# group: robin
user::rwx
user:alex:r-x
group::—
mask::r-x
other::—
##使用alex账户访问robin可以正常访问
[robin@localhost /home]$exit
[alex@localhost /home]$cd robin/
[alex@localhost /home/robin]$ls
Advertisements
This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s