Working with files and dirs Flashcards
Set GID
mkdir -p /dir1/{finance,it}
chmod g+s /dir/it
getfacl
Supports only in xfs, ext4
getfacl /dir1
setfacl to user and group
setfacl -m u:it_user:rx /dir1
setfacl -m g:it:rx /dir1
Change max level of permissions assigned to mask in facl
setfacl -m m::rwx /dir1
setfacl -m m::- /dir1 -remove all privileges and set mask to —
Set default facl for user it_user
Remove default permissions
1. setfacl -d -m u:it_user:rw /dir1 so all files and dirs inside dir1 will have default privileges 2. setfacl -m u:it_user:rwx /dir1 3. cd dir1 4. touch file1 5. getfacl file1=> it_user will get default facl ie rw-
setfacl -x /dir1 -remove default permissions
Remove facl permissions
Remove facl default permissions
setfacl -x u:it_user /dir1
setfacl -x d:u:it_user /dir1
Set facl to multiple users or groups
setfacl -m g:finance:rwX,u:it_user:rw /dir1
Copy facl from one file to another
getfacl file1 | setfacl –get-file=- file2
so –get-file=- (minus in this case means output from getfacl file1)
Allow group to traverse through dirs inside, but do not apply execute permissions to files inside the /dir1
chmod -R g+rwX /dir1
Which FSs support ACL
xfs, ext4
What mask sets on ACL
Sets max permission level even if DAC does not match and have less permission access
Change mask on ACL
permissions before: 777, mask=rwx 1. chmod 444 file1 => mask=r-- even ACL for a user=Bob is still = rwx 2. setfacl -m m::r file1 => mask=r-- even ACL for a user=Bob is still = rwx Therefore, Bob will be able to read from file, but will not be able to write to or execute file1
Set mask=none on ACL
sefacl -m m::- file1
but when running later:
setfacl -m g:finance:rw file1
mask will change to mask=rw-
Set default ACL
ls -la => dir1 drwxr-xr-x
setfacl -d -m u:Bob:rw dir1
getfacl dir1 =>
user: :rwx
group: :r-x
other: :r-x
default: user::rwx
default: user:Bob:rw-
default: group::r-x
default: mask::rwx
default: other::r-x
Therefore user Bob will not be able to create files in dir1, since there are no regular permissions for Bob, there are only default.
we need to setfacl -m u:Bob:rwx dir1
and Bob will be able to create files in dir1
Remove default permissions on ACL
setfacl –remove-default dir1