Day 6 - File Permissions and Access Control Lists

Day 6 - File Permissions and Access Control Lists

$ sudo useradd tom

created a user named tom

$ sudo chown tom backupfile.tar.gz

#changed the user permissions for bachupfile.tar.gz from ubuntu to tom user

$ sudo chown :tom backupscript.sh

#changed the group permissions of backupscript.sh file from ubuntu to tom group

File Permissions

File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how.

The ls command along with its -l (for long listing) option will show you metadata about your Linux files, including the permissions set on the file.

$ ls -l

drwxr-xr-x. 4 root root    68 Jun 13 20:25 tuned
-rw-r--r--. 1 root root  4017 Feb 24  2022 vimrc

In this example, you see two different listings. The first field of the ls -l output is a group of metadata that includes the permissions on each file. Here are the components of the vimrc listing:

  • File type: -

  • Permission settings: rw-r--r--

  • Extended attributes: dot (.)

  • User owner: root

  • Group owner: root

The fields "File type" and "Extended attributes" are outside the scope of this article, but in the featured output above, the vimrc file is a normal file, which is file type - (that is, no special type).

0→ No permissions

1 →Only execute

2 →Only write

3 →Execute & write

4 →Only read

5 →Read & execute

6 →Read & write

7 →Read, write & execute

Chmod 777 <Filename>

User group others have all permissions

Chmod 765 <Filename>

User group others

Rwx rw- r-x


ACL stands for access control list in Linux which is similar to chmod to change the permission of a particular file.

sudo apt install acl

getfacl <file name>

gives us the complete infomation about the file

setfacl -m g:ubuntu:r directory.sh

Here setfacl is changing the group permissions of directory.sh file to only readble from read/write/execute.