Skip to Content
This project is a work in progress. If you have any questions or suggestions, feel free to contact me.
LinuxPermissions & SecurityFile Permissions

Permissions

Linux is a multi-user operating system with a robust file permission system to control access to files and directories. Every file and directory has an owner, a group, and access rights defined for the owner, the group, and all other users (others). These permissions determine who can read, write, or execute a file or directory.

Types of Permissions

There are three basic permission types:

  • Read (r): Ability to view the contents of a file or list a directory.
  • Write (w): Ability to modify a file or add/delete files in a directory.
  • Execute (x): Ability to run a file as a program or enter a directory.

Permission Values Table

PermissionSymbolNumeric ValueFile MeaningDirectory Meaning
None-0No accessNo access
Executex1Run a fileEnter or traverse directory
Writew2Modify file contentsAdd/delete files
Readr4View file contentsList contents

These values are combined using addition. For example, read + write = 4 + 2 = 6.

Permission Representation

Linux permissions are shown with ls -l. Example:

-rwxr-xr--

This means:

  • File type: - (regular file)
  • Owner: rwx (read, write, execute)
  • Group: r-x (read, execute)
  • Others: r-- (read only)

Ownership and Groups

Every file or directory has:

  • Owner (user who created it)
  • Group (user group associated with the file)
  • Others (all other users on the system)

Permissions are defined separately for each of these.

Permission Commands and Syntax

chmod – Change file or directory permissions

Symbolic mode example:

chmod u+x script.sh

Octal mode example:

chmod 755 script.sh

chown – Change ownership (user or user:group)

chown alice file.txt chown alice:devs file.txt

chgrp – Change group ownership

chgrp devs file.txt

Command Summary Table

CommandPurposeExample
ls -lView file permissionsls -l
chmodModify permissionschmod 644 file.txt
chmod -RChange permissions recursivelychmod -R 755 /project
chownChange file ownerchown alice file.txt
chown user\:groupChange owner and groupchown alice:devs file.txt
chgrpChange group onlychgrp devs file.txt
Last updated on