Linux File Permissions

Ankit KondalAnkit Kondal
2 min read
  1. Open the terminal, navigate to the desired directory

  2. Create an empty file using the touch command

  3. Confirm the creation with ls -l

A hyphen denotes a regular file, while a "d" signifies a directory.

File or directory permissions are managed via commands :

chmod, chown, and chgrp

Chmod : It allows users to modify file permissions. It modify read, write, and execute permissions for the owner, group, and others, enhancing security and control over file access.

It can be represented by symbolic or numeric expressions

Symbolic representation: chmod u+rx,g-rwx,o+w [file.txt]

Numeric representation: chmod 777 [file.txt]

Chown : The chown command in Linux is used to change the ownership of files and directories.

Syntax is chown [new_owner]:[new_group] file

Initially, the file "demo2.txt" was owned by the user "ubuntu" and belonged to the group with the same name. After executing the chown command, the ownership successfully changed the to "user1"

Chgrp : The chgrp command in Linux is used to change the group ownership of a file or directory. This command allows users to modify the association of a file or directory with a specific group.

ACL (Access Control List) :

It offers advanced permissions beyond the standard owner, group, and others model.

'getfacl' to view ACL entries for a file or directory, revealing detailed user-specific permissions.

'setfacl' to modify ACLs, granting or revoking permissions for users or groups.

setfacl -m u:user1:rwx allows user "user1" read write and execute access.

Provides granularity enhances access control .

0
Subscribe to my newsletter

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

Written by

Ankit Kondal
Ankit Kondal