# Day 7 File Permissions and Access Control Lists.
File Permissions:
Today is more on Reading, Learning and Implementing File permissions
The concept of Linux File permission and ownership is important in Linux. Here, we will be working on Linux permissions and ownership and will do tasks on both of them. Let us start with the Permissions.
File permissions in Unix-like operating systems (such as Linux) are represented by a set of three groups: user, group, and others. Each group has its own set of permissions: read (r), write (w), and execute (x). Here's a breakdown of what each permission allows:
Read (r): Allows the user to view the contents of a file or directory.
Write (w): Allows the user to modify or delete a file or directory.
Execute (x): Allows the user to execute a file (for executable files) or access a directory (for traversal).
File permissions are represented using symbolic notation or numeric notation. Symbolic notation uses characters like "r", "w", and "x", while numeric notation assigns a numeric value to each permission (4 for read, 2 for write, and 1 for execute) and calculates the sum of these values to represent permissions
Change the permissions of the file and explain the changes.
After executing the chmod 755 file.txt
command on a file named file.txt
, the file permissions are modified according to the numeric notation:
The owner of the file (
file.txt
) will have read (4), write (2), and execute (1) permissions, denoted as7
(4 + 2 + 1).The group associated with the file will have read (4) and execute (1) permissions, denoted as
5
(4 + 0 + 1).Other users will have read (4) and execute (1) permissions, denoted as
5
(4 + 0 + 1).
So, after executing chmod 755 file.txt
, the file permissions for file.txt
will be set as follows:
Owner: Read, Write, Execute (rwx)
Group: Read, Execute (r-x)
Others: Read, Execute (r-x)
In summary, the chmod 755 file.txt
command grants the owner full access to the file, while allowing the group and other users to read and execute the file, but not modify it.
ACL
Understanding Access Control Lists (ACLs) with getfacl and setfacl.
Access Control Lists (ACLs) offer a powerful way to manage file and directory permissions in Unix-like operating systems, providing finer control over access rights than traditional permissions. Two essential commands for working with ACLs are getfacl
and setfacl
, which allow users to view and modify ACLs respectively.
If it is not installed on your server, you can install it with the below command.
sudo apt install acl
getfacl Command:
The getfacl
command is your window into understanding existing ACLs on files and directories. It provides a clear overview of who has what permissions.
setfacl Command:
The setfacl
command empowers you to modify ACLs, enabling you to grant or revoke specific permissions to users and groups.
setfacl [options] [ACL_entry] [file or directory]
Options:
-m
: Modify existing ACLs-x
: Remove existing ACL entries-b
: Remove all existing ACL entries
Creating new user akshay and granting read and write permissions to the user akshay
on file.txt
:
Remove all permission of user akshay and delete the user.
"Thank you for joining me on this journey into DevOps! Your curiosity is the driving force behind this exploration. If you found value in these insights, I'm thrilled! Keep the DevOps flame alive, and stay tuned for more exciting adventures in the world of technology. Happy Learning! 🚀✨"
"Closing the gap between us—let's connect and make our virtual bond stronger on social media!
Click on -Umesh Salunkhe