In Linux, file permissions determine who can read, write, and execute files or directories. We can check this using "ls -l" command, it will display a list of files and directories with their permissions, owner, groups, size, and modification dates.
Owner (u): It determines the permission for the user.
Group (g): It determines the permission for groups
Others (o): It determines the permission for other users
In Linux, file permissions are represented by numbers as well as letters. Here's a chart that shows how the numbers correspond to the permissions:
chown <owner> <file_name>: By using this command we can change the owner of files and directories
chgrp <group> <file_name>: This command is used to change group of files and directories
chmod: This command is used to change read, write, and execute permissions of users, groups and others
For Example,
chmod 770 demo.txt : Here 7 means (r+w+x) permission for user and group and no permission for others.
Access Control List(ACL):
Access Control List (ACL) is a more advanced and flexible permission system that can be used in Linux.
By using ACLs, you can set permissions for individual users and groups, allowing you to grant or restrict access to specific files and directories as needed.
getfacl <file/dir-name>: This is used to check the ACL's permission.
setfacl -m u: Rohit:rwx /<file/dir-name>: This is used to set ACL's permission for users.
setfacl -x u: Rohit: /<file/dir-name>: This is used to remove ACL's permission for users.
Overall, ACLs are a more powerful and flexible mechanism for access control, particularly in complex environments with many users and groups. However, general file permissions remain a useful and simple approach for many basic access control needs.
Thank you for reading the blog.
Suggestions are always welcome. Thank you !!