File Permissions and Access Control Lists

Ahmed NisarAhmed Nisar
3 min read

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.

  1. Create a simple file and do ls -ltr to see the details of the files

    Each of the three permissions are assigned to three defined categories of users. The categories are:

    1. ๐Ÿ‘คowner โ€” The owner of the file or application.

    2. ๐Ÿ‘ฅ๐Ÿ‘ฅgroup โ€” The group that owns the file or application.

    3. ๐ŸŒ๐Ÿ‘ฅothers โ€” All users with access to the system. (outside the users are in a group)

  2. Change file permission of a file:

    1. ๐Ÿ‘‘๐Ÿ‘ค"chown" is used to change the ownership permission of a file or directory.

    2. ๐Ÿ‘‘๐Ÿ‘ฅ"chgrp" is used to change the group permission of a file or directory.

    3. ๐Ÿ‘‘๐Ÿ‘ฅ๐ŸŒ "chmod" is used to change the other users permissions of a file or directory.

As a task, change the user permissions of the file and note the changes after ls -ltr

create a .txt file and see the permission (read and write permissions to owner and group and read only for other users)

add the permission for others to write the test.txt file

and change the group from ubuntu to ahmed

sdas

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

๐Ÿ”’ File permissions in Linux are like a lock on a door. They control who can do what with a file or directory.

๐Ÿ”‘ three main types of users can access a file:

the owner, the group, and others (everyone else).

๐Ÿ” Each type of user can have three types of permissions:

  • Read ๐Ÿ“–: Allows you to see the contents of the file.

  • Write โœ๏ธ: Allows you to make changes to the file.

  • Execute ๐Ÿƒโ€โ™‚๏ธ: Allows you to run the file if it's a program or enter a directory.

๐Ÿ‘ค๐Ÿ”“ The file owner has special powers and can change the permissions, read, write, and execute the file.

๐Ÿ‘ฅ๐Ÿ”’ The group members have permissions that the owner has set for them.

๐ŸŒ๐Ÿ”’ Others are all the rest of the users who don't own the file or belong to the group.

๐Ÿ—๏ธ You can set these permissions using numbers (0-7) or letters (r, w, x) to make sure your files are safe and only accessible to the right people.

Read about ACL and try out the commands getfacl and setfacl

๐Ÿ”’๐Ÿ“‚ Access Control Lists (ACLs) are an extension of the standard Linux file permissions that provide more granular control over access rights for files and directories. ๐Ÿ—๏ธ While traditional Linux file permissions (user, group, others) offer three levels of access (read, write, execute) for the owner, group, and other users, ACLs allow you to define permissions for specific users or groups beyond those categories. ๐Ÿ‘ฅ๐Ÿ”

With ACLs, you can finely tune access privileges, granting or revoking permissions for individual users or groups, empowering you to manage file access in a more flexible and nuanced manner. ๐Ÿ› ๏ธ๐Ÿ”

try to install acl on ubuntu: sudo apt install acl

use setfacl to add read and write permissions for ubuntu and read permission for ubuntu to the test.txt file.

To view the ACL entries for the file, use the getfacl command:

0
Subscribe to my newsletter

Read articles from Ahmed Nisar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ahmed Nisar
Ahmed Nisar

AWS Devops | Linux | Docker | Jenkins | Terraform | Kubernetes | Ansible |