4. Data Sharing
Users should use File Access Control Lists (FACL) to share their data and collaborate with other users. FACL mechanism allows a fine-graiNet control access to any files by any users or groups of users. FACL allows to grant access without modifying file ownership and without changing POSIX permissions.
Warning
Users are discouraged from setting ‘777’ permissions with chmod, because this can lead to data loss (by a malicious user or unintentionally, by accident).
ACL mechanism, just like regular Linux access controls (POSIX), allows three different levels of access control:
Read (r)
Write (w)
Execute (x)
This level of access can be granted to
user (owner of the file)
group (owner group)
other (everyone else)
4.1. View Permissions
Use getfacl
to retrieve access permissions for a file.
getfacl myfile.txt
# file: myfile.txt
# owner: ab123
# group: users
Expected output:
user::rw-
group::---
other::---
The example above illustrates that in most cases ACL looks just like the chmod-based permissions: owner of the file has read and write permission, members of the group and everyone else have no permissions at all.
Tip
You can see with ‘ls -l’ if a file has extended permissions set with setfacl: the ‘+’ in the last column of the permissions field indicates that this file has detailed access permissions via ACLs:
ls -la
Example Output:
total 304
drwxr-x---+ 18 ab123 users 4096 Apr 3 14:32 .
drwxr-xr-x 1361 root root 0 Apr 3 09:35 ..
-rw------- 1 ab123 users 4502 Mar 28 22:27 my_private_file
-rw-r-xr--+ 1 ab123 users 29 Feb 11 23:18 dummy.txt
4.2. Modify Permissions
Permisions can be modified by setfacl
commmand.
# General syntax:
setfacl -[options] [action/specification] <file/dir>
Options:
-m
- modify-x
- remove-R
- recursive (apply ACL to all content inside a directory)-d
- default (set given settings as default - useful for a directory - all the new content inside in the future will have given ACL)-b
- Remove all extended ACL permissions.
Specifications:
u:NetID:permissions
for sharing with a user.g:GroupName:permissions
for sharing with a group.o:NetID:permissions
for sharing with everyone.
Permissions:
---
,r
for read,w
for write,x
for execute, for example to give only read write permissions userw-
.
4.2.1. Examples
4.2.1.4. Remove permissions for a user
#setfacl -x "entry" <file/dir>
setfacl -x "u:abc123" <file/dir>
4.2.1.5. Remove all permissions
# setfacl -b <file/dir>
setfacl -b abc.txt
Useful Link