Linux Permissions - Files and Directories

This document is incomplete, it’s being actively worked on by Patrick.

File and Directory - Ownership

  • chown command (user and groups).
  • chgrp command (groups).

File and Directory - Read/Write/Execute Permissions

The permissions are handled by the “chmod” command.

chmod <permission> <filename/directory name>
chmod 777 filename
chmod 777 directory_name

Permissions Calculator Table

Read (r) Write (w) Execute (x) No Permission (-)
Owner 400 200 100 0
Group 40 20 10 0
Public 4 2 1 0

To create permissions, you add up the values above.

Example 1: If you want to give a file only read permission for every level, you will add 400+40+4. This will create 444 as the permissions set (r–r–r–).
Example 2: If you want to give read and write access to the owner, and the group, but only read access to public you would add up the values 400+200+100+40+20+10+4. This will create a 774 as the permissions set (rwxrwxr–).
Example 3: If you want to give the owner full access, then everyone else no access you will use 7 for the owner, 0 for the group, and 0 for the public. This will create a 700 as the permission set (rwx——).

File and Directory Permissions - Over Explained for Nerds

This is stuff that you don’t need to know to manage file permissions, but you might want to know.

Linux uses 3 bits of data to set the permission of a file or directory, which give you the ability to set the octal (base-8 number) with 8 numbers between 0 and 7. The Octal Representation table below explains how that works.

Octal Representation

Octal Value (0-7) Binary Value Visual Permissions Description of Permissions
0 000 - - - No Permissions
1 001 - - x Only Execute
2 010 - w - Only Write
3 011 - w x Write and Execute
4 100 r - - Only Read
5 101 r - x Read and Execute
6 110 r w - Read and Write
7 111 r w x Read, Write, and Execute