File Permissions and Access Control Lists

File Permissions and Access Control Lists

Table of contents

#90DaysofDeVops #Day6

File permission and Access control Lists (ACLs) are security mechanisms used in Linux to control access to files and directories. It allows us to specify who can read, write, and execute files, as well as control what other users or groups can do with the files.

File Permissions

File permissions are a set of rules that determine who can read, write, and execute files on a Linux system. In Linux, each file and directory is associated with an owner and a group, and there are three types of permissions for each file or directory: read (r), write (w), and execute (x).

The permission settings for a file or directory can be viewed using the "ls -la" command.

ls -la
ls -ltr

For Changing permissions

chmod u+r /ash.txt
chmod g+rw /ash.txt
chmod o-r /ash.txt

For Changing Ownership OR Group Ownership:

Syntax : chown <username><file/directoryname> or chown <groupusername><file/directoryname>

chown ubuntu /ash.txt

For Changing permission through numeric value.

chmod 751 /ash.txt

Access Control List

It provides additional or more flexible permissions mechanisms for file systems. It can even provide special permissions for specific user and groups to particular directories and files.

Using ACL in case the user is not part of the group and still requires a read/write access then ACL comes to the rescue.

getfacl /ash

To set ACL user permission.

setfacl -m u:ash:rwx /dir
setfacl -x u:ash /dir   # To remove the permissions
# For group permissions use g instead of u.
setfacl -b /dir  #Removes all the permissions