<< back to Guides

Quick Guide to Changing Permissions in Linux

This guide explains how to change file and folder permissions in Linux using the chmod command, including recursive operations. This guide also includes a permission cheat sheet.


Changing Permissions for Files and Folders

  1. Basic Syntax for chmod:
chmod [permissions] filename

Replace [permissions] with the desired permission values and filename with the actual file or folder name.

  1. Using chmod Recursively: To change permissions for a folder and all its subdirectories and files, use the -R option:
chmod -R [permissions] foldername
  1. Running chmod as Root: If a file or folder is owned by root or another user, you may need sudo to change its permissions:
sudo chmod [permissions] filename
  1. Numeric vs. Symbolic Permissions:

Cheat Sheet: Permission Codes

Permission Numeric Symbolic Meaning
r 4 r Read
w 2 w Write
x 1 x Execute
- 0 - No permission

Common Permission Values

Numeric Code Symbol Permissions for user, group, others
777 rwxrwxrwx Read, write, and execute for all
755 rwxr-xr-x Full for user, read/execute for group and others
644 rw-r--r-- Read/write for user, read for group and others
700 rwx------ Full for user, none for group and others

Examples

chmod 644 myfile.txt

This gives the owner read and write permissions, while others have read-only access.

chmod -R 755 myfolder/

This sets full permissions for the owner, and read/execute for everyone else on all files and subfolders.

chmod u+rwx,go+rx myfile.txt

This grants the user full permissions, and read/execute permissions to group and others.

<< back to Guides