Tutorial

Linux Permissions Guide

Understanding chmod, chown, and the Linux permission model.

What Are Linux Permissions?

Every file and directory in Linux has three types of permissions: read (r), write (w), and execute (x). These are assigned to three categories: owner (u), group (g), and others (o).

Permission Numeric Values

Value Permission Symbol
7Read + Write + Executerwx
6Read + Writerw-
5Read + Executer-x
4Read Onlyr--
3Write + Execute-wx
2Write Only-w-
1Execute Only--x
0No Permissions---

Common chmod Examples

bash
chmod 755 script.sh     # rwxr-xr-x
bash
chmod 644 index.html    # rw-r--r--
bash
chmod 700 private.key   # rwx------
bash
chmod +x script.sh      # Add execute for all
bash
chmod -R 755 /var/www/  # Recursive on directory

chown — Change Ownership

Change which user and group owns a file.

bash
sudo chown tom:www-data file.txt
sudo chown -R www-data:www-data /var/www/html

Quick Quiz

What does chmod 644 do?

Home Buy Me a Beer