File Permissions and Access Control Lists

File Permissions and Access Control Lists

·

3 min read

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

ls -ltr

Here,

ls --> list of all files and directories present in the present working directory.
-l --> long listing.
-r --> reverse order, which is used to reverse the order of listing.
-t --> sort files and directories with their last modification time.


👉Write an article about File Permissions based on your understanding.

File permissions are used to control the access of a particular user to a particular file or directory.

-rw-rw-r-- 1 ubuntu ubuntu 0 Jan 08 16:22 file11

Here the first hyphen "-" indicates it is a file, if there is "d" instead of the hyphen then it is a directory, not a file.

then

rw- --> owner of a file
rw- --> group
r-- --> others

12345 6 7 8 9 10
-/drw-r - x r - -
File typeOwner PermissionsGroup PermissionsOther user Permission- Not in Group
4+2+0 = 64+0+1 = 54+0+0 = 4
Absolute modeSymbolMode
1-x-execute
2-w-write
4-r-read
0--null

Suppose we want to give read, write and execute permissions to the owner and read permission to the group and others, then

For read, write and execute --> 4+2+1 = 7

For read --> 4

So, the command is like

chmod 744 file11

Output: -rwxr--r-- 1 ubuntu ubuntu 0 Jul 19 16:22 file14


👉Read about ACL and try out the commands getfacl and setfacl

ACL commands are used to provide temporary permissions to a particular user or group without changing the actual permission of files or directories.

There are 2 ACL commands i.e getfacl and setfacl

setfacl --> used to set additional/temporary permission of a file/directory.

getfacl --> used to show additional permission of a file/directory.

Now will set executable permission to the new user(tejal) using setfacl command

setfacl -m "u:tejal:x" file11

To add temporary permission to "devops" group using setfacl command

setfacl -m "g:devops:rwx" file11

Group permission is also added in the above example(screenshot).

◾ To remove all acl permission from a file or directory

setfacl -b file11

◾ To remove specific entry,

setfacl -x "g:devops" file11

Happy Learning!!

Thanks For Reading 🙂