Linux File Permissions Cheat Sheet

Linux file permissions are used to control who can access, modify, and execute files and directories in a Linux system. Here is a cheat sheet to help you understand and manage Linux file permissions:

Types of Access

There are three types of access in Linux file permissions:

Type of AccessSymbolDescription
ReadrAllows the user to view the contents of a file or directory.
WritewAllows the user to modify the contents of a file or directory.
ExecutexAllows the user to execute a file or access the contents of a directory.

File Permission Notation

Linux file permissions are represented in a 10-character string of letters and symbols. Here’s how to read it:

CharacterMeaning
1stFile type and any special permissions
2-4Owner permissions
5-7Group permissions
8-10Others permissions

The first character in the string represents the file type and any special permissions. The remaining nine characters represent the owner, group, and others’ permissions, in sets of three.

Numeric Permission Notation

Numeric permission notation is another way to represent Linux file permissions. Here’s how to read it:

PermissionNumericSymbolic
No permissions0
Execute1x
Write2w
Write and execute3wx
Read4r
Read and execute5rx
Read and write6rw
Read, write, and execute7rwx

Each permission set is assigned a number, from 0 to 7, based on the binary representation of the permission bits. For example, a permission string of “rw-r–r–” would be represented in numeric notation as “644.”

Managing File Permissions

Here are some commands to manage file permissions in Linux:

CommandDescription
chmodChange the permissions of a file or directory.
chownChange the owner of a file or directory.
chgrpChange the group of a file or directory.

Examples

To change the permissions of a file named example.txt to read and write for the owner and read-only for everyone else:

chmod 644 example.txt

To change the owner of a file named example.txt to newowner:

chown newowner example.txt

To change the group of a file named example.txt to newgroup:

chgrp newgroup example.txt


Octal Table:

Here is a table that explains the octal, binary, and symbolic values used in Linux file permissions:

OctalBinarySymbolicPermission Type
0000No permissions
1001–xExecute
2010-w-Write
3011-wxWrite/execute
4100r–Read
5101r-xRead/execute
6110rw-Read/write
7111rwxRead/write/execute

Also, see the example code shell-scripting-examples in our GitHub repository. See complete examples in our GitHub repositories.

Follow us on social media
Follow Author