Day 6 of #90daysofdevops
Hey Techies! Welcome to this blog
In this blog, we are going to discuss File Permissions and Access Control Lists.
In Linux, file permissions refer to the settings that determine who can read, write, or execute a file or directory. The permission settings are represented by a series of letters and numbers, and they can be set for the owner of the file, the group that the file belongs to, and other users who are not the owner or a member of the group.
owner - The owner of the file or application.
-> "chown" is used to change the ownership permission of a file or directory.
group - The group that owns the file or application.
-> "chgrp" - is used to change the group permission of a file or directory.
others - All users with access to the system. (outside the users are in a group)
-> "chmod" - is used to change the other user's permissions of a file or directory.
Create a simple file and do
ls -ltr
to see the details of the files.ls -ltr
command to list the files in the directory, sorted by modification time with the latest files appearing at the end of the list. You should see the file you just created, along with its details such as permissions, owner, group, size, and modification time.
- Write an article about File Permissions based on your understanding from the notes.
File Permissions in Linux: Understanding User, Group, and Other Permissions.
Read (r): Grants permission to read the contents of a file or list the contents of a directory.
Write (w): Grants permission to modify a file or create, delete, and rename files within a directory.
Execute (x): Grants permission to execute a file (if it is a program or script) or access and traverse a directory.
Read about ACL and try out the commands
getfacl
andsetfacl
Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.
The
getfacl
andsetfacl
commands are used to view and modify the ACLs for files and directories.getfacl
: Thegetfacl
command is used to display the ACLs for a file or directory. The syntax is as follows:getfacl filename
For example, to display the ACLs for a file called "example.txt", you would use the following command:
getfacl example.txt
The output of the command will show you the access permissions for the file or directory, including the owner, group, and any additional users or groups with specific permissions.
setfacl
: Thesetfacl
command is used to set or modify the ACLs for a file or directory. The syntax is as follows:setfacl options filename
For example, to grant read and write access to a specific user, you could use the following command:
setfacl -m u:kritika:rw example.txt
This command adds the "rw" (read and write) permissions for the user "atharv" to the file "example.txt". The "-m" option specifies that we are modifying the ACLs, and "u:atharv" specifies that we are modifying the ACLs for the user "atharv". You can also use the
-x
option to remove an ACL entry, and the-b
option to remove all ACLs from a file or directory.
Thank you so much for taking the time to read till the end! Hope you found this blog informative and helpful.
Feel free to explore more of my content, and don't hesitate to reach out if need any assistance from me or in case of you have any questions.
Happy Learning!
~kritika :)
Connect with me: https://www.linkedin.com/in/kritikashaw
Follow my Blog channel: https://hashnode.com/@kritikashaw