Essential Guide to Linux File Permissions

Essential Guide to Linux File Permissions

Permission

  • Permissions in Linux plays an important part in administration as well as application configuration.

  • Whether you are a system administrator or a developer, it is mandatory to understand how permissions work in Linux systems.

  • Linux file permissions are a set of rules that determine who can access, modify, and execute files and directories on the system.

Displayed using the ls -l command in the terminal :

Types of Permissions:

  • Read (r): Allows a user to view the contents of a file or directory.

  • Write (w): Allows a user to modify or delete a file or directory.

  • Execute (x): Allows a user to run a file as a program or execute a directory as a script.

User, Group and Others (UGO) :

  • User: The user who owns the file or directory.

  • Group: Users who are part of the file's or directory's group.

  • Others: All other users who are not the owner or part of the group

Permissions Representation:

Read, write, and execute permissions can also be represented using octal notation.

  • Read (r): 4

  • Write (w): 2

  • Execute (x): 1

Combining Permissions: Permissions can be combined by adding their octal values.

For example, if a file has read, write, and execute permissions, it is represented as 7 (4 + 2 + 1 = 7).

Commands :

CommandInfoSyntaxExample
chmodChanging permissions of a filechmod (permission-to-be-assigned) (path-to-file)chmod 700 file.txt
chownChange the ownership of a filechown (user-to-be-assigned) filenamechown admin file.txt