Day 6 - 90DaysofDevops
File Permissions and Access Control Lists
"chmod" is the command to provide permission for file/directory.
chmod <permission_value> <file_name>
$ sudo chown kumar 23-06-06_16-19-16.tgz
#changed the user permissions for 23-06-06_16-19-16.tgz from bipul to kumar user
Read, write, execute and –
The ‘r’ means you can “read” the file’s contents.
The ‘w’ means you can “write”, or modify the file’s contents.
The ‘x’ means you can “execute” the file. This permission is given only if the file is a program.
If any of the “rwx” characters is replaced by a ‘-‘, then that permission has been revoked.
If the permission is given as 777 as per the below mode, then the user will have full access to the folder or file. This is not advisable if the user is not a root user.
Symbolic | Mode | Absolute Mode |
r | read | 4 |
w | write | 2 |
x | execute | 1 |
(-) | Null | 0 |
ACL
ACL stands for Access Control Lists.
Think of a scenario in which a particular user is not a member of group created by you but still you want to give some read or write access, how can you do it without making the user a member of the group, here comes in picture Access Control Lists, ACL helps us to do this trick.
ACLs are used to make a flexible permission mechanism in Linux.
sudo apt install acl
getfacl is the command to show what are permission assigned to any file/folder.
setfacl is the command used to grant permission to any file/folder.
getfacl <file or foldername>
setfacl -m "u:user:permissions" /path/to/file
setfacl -m "g:group:permissions" /path/to/file