Day 6: File Permissions and Access Control Lists

Day 6: File Permissions and Access Control Lists

ยท

4 min read

Hello Dosto

Welcome back to my #90DayDevOps blog. Today we learn about File Permissions where we'll create one file and try to change their permission and Access Control lists.

Let's get started. So our first task will be

  1. Create a simple file and do ls -ltr and check & modify its permissions.

In the above screenshot, you can see I have created a file named day06.txt and I checked its permissions with the ls -ltr command

The file has -rw-rw-r-- permission at this place I would like to inform you about how permissions are categorized in Linux.

Understanding Linux Permissions and chmod Usage

As this file has -rw-rw-r-- permission i.e. we can divide these into 3 parts rw- : Owner,rw- : Group, r-- : Other.

Now, let's change the file permission.

I have given 777 permission to this file by running chmod 777 day06.txt and after that when I listed the permission it showed me that the file has -rqxrwxrwx permission which means that user vboxuser can perform all tasks over this file.

  1. Write an article about File Permissions based on your understanding from the notes.

    Linux file permissions are a fundamental aspect of the Linux operating system that controls access to files and directories. They are crucial for maintaining security and ensuring that files are used appropriately. Linux file permissions consist of three components:

    1. User Permissions (Owner):

      • Read (r): Allows the owner to view the file's contents.

      • Write (w): Permits the owner to modify the file.

      • Execute (x): Grants the owner permission to run the file if it's a script or program.

    2. Group Permissions:

      • Read (r): Allows the group members to view the file's contents.

      • Write (w): Permits the group to modify the file.

      • Execute (x): Grants the group permission to run the file if applicable.

    3. Others Permissions:

      • Read (r): Allows others (those not in the owner group or owning the file) to view the file's contents.

      • Write (w): Permits others to modify the file.

      • Execute (x): Grants others permission to run the file if applicable.

Additional concepts related to Linux file permissions include the setuid (SUID) and setgid (SGID) bits, which can be set to enable a process to run with the permissions of the file owner or group owner, respectively. The sticky bit is another permission that prevents users from deleting or renaming files in directories they don't own.

Alex Xu on X: "Linux file permission illustrated. To understand Linux file  permissions, we need to understand Ownership and Permission.  https://t.co/HMKOivuifo" / X

To manage Linux file permissions, you can use the chmod command to change them. Understanding and appropriately setting file permissions is crucial for ensuring the security and proper functioning of a Linux system.

  1. Read about ACL and try out the commands getfacl and setfacl

    ACL (Access Control Lists): Access Control Lists (ACLs) are a more flexible way of setting permissions on files and directories compared to the traditional Unix file permissions. ACLs allow you to define access rights for users and groups beyond the owner, group, and others. ACLs are commonly used in situations where finer-grained control is needed. ACLs can be set and managed using the setfacl command.

    getfacl Command: The getfacl command is used to retrieve and display the Access Control List (ACL) of a file or directory. It shows the permissions granted to users and groups that are not covered by the standard file permissions. For example, if you want to see the ACL of a file, you can run:

    This command will display the ACL entries for that file.

    setfacl Command: The setfacl command is used to set or modify the Access Control List (ACL) for a file or directory. It allows you to grant or revoke specific permissions to users and groups. For example, to grant read and write access to a user, you can run:

    This command adds a rule to the ACL, allowing the specified user to read and write the file.

    Both getfacl and setfacl are powerful tools for managing permissions in a more detailed and fine-grained way compared to traditional Unix permissions. They are particularly useful in scenarios where you need to provide different access rights to various users and groups on the same file or directory.

Feel free to leave any questions in the comments. I'd be happy to answer them๐Ÿ˜„.

Happy Learning ๐Ÿ’š

#90DaysOfDevOps

ย