Linux File permission and ownership !

Linux File permission and ownership !

Today's focus lies on the topics of Reading, Learning, and Implementing File Permissions in the context of Linux. Understanding Linux file permissions and ownership is a crucial aspect of working with Linux systems. In this session, we will delve into the world of Linux permissions and ownership, and engage in practical tasks related to both. Let's begin by exploring the realm of Permissions.

File permissions serve as the gatekeepers, governing who can read, write, and execute a file. These permissions come in three distinct types: Read (r), Write (w), and Execute (x). we can easily understand through the below image.

For more versatile and fine-grained control over file and directory permissions, Access Control Lists (ACLs) offer a modern approach. They provide an alternative to the traditional Unix file permissions, making them particularly useful in scenarios where precise control is required. To manage ACLs, you can utilize the "setfacl" command, and to view and display the Access Control List (ACL) of a file or directory, the "getfacl" command comes into play.

As a practical exercise, we can start by creating a simple file and then employ the "ls -ltr" command to examine the file's details, as mentioned in your notes.

It's important to note that each of the three fundamental permissions is assigned to specific categories of users, which include:

"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. (outised the users are in a group)

"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

we have created one blank directory and txt file and we could see access permission using ls -l command

now we could see testfile.txt has -rw-rw-r-- . for better understanding, we divide this value in 4 parts

1) - file type

2)rw- it shows permission of the user (read, write, - (no execute))

3) rw- it shows permission of group (read, write,- (no execute))

4) rw- it shows permission for another user. (read, write,- (no execute))

Here first - (blank) value shows whether is it a file or a directory.

For data folder, we could see d while for testfile its blanks mean its file.

now we can change permission on the user level or group level.

for the user level will change permission and give user to execute right with 2 different way

1) using u+rwx(here 'x' denotes execute right to user)

2) Using rights value chmod 764
here access value calculation (read 4+write 2+execute 1=7) for the current user
(read 4 + write 2=6) for group
(read 4 ) for others

same way we can change permission at the group level or for other users

now we could see testfile all three sets having full permission rwx to user, group and others.

file permission weightage we can also calculate with the below table.

Thanks,

Kishor Chavan