"Permission Denied." It is one of the most common errors in Linux development and administration. When fixing it, developers often scramble between two commands: chmod and chown. While they seem similar, they control completely different layers of the Linux security model. To set access levels, try our client-side Chmod Calculator, or use our visual Chown Command Generator to set file ownership 100% locally in your browser.
Chmod: Changing Who Can Do What
The chmod command stands for "change mode." It determines the **access permissions** of a file or directory. Every file has permissions divided into three classes of users:
- Owner (u): The individual user who owns the file.
- Group (g): A collection of users associated with the file.
- Others (o): All other users on the system.
Each class is assigned three possible actions: **Read (r)**, **Write (w)**, and **Execute (x)**. Chmod allows you to toggle these bits using either symbolic representation (e.g., chmod +x script.sh) or octal numeric representation (e.g., chmod 755 public_html).
Chown: Changing Who Owns the File
The chown command stands for "change owner." It determines the **identity** of the user and group that own the file. A file can have one owner and one group.
For instance, running:
sudo chown www-data:www-data index.html
Assigns the owner to the www-data user and the group to the www-data group (which is the standard setup for Nginx and Apache web servers).
How Permissions and Ownership Interact
Linux evaluates permissions from the inside out:
- If the user trying to access the file is the **Owner**, Linux checks only the Owner permissions.
- If the user is not the owner but belongs to the file's **Group**, Linux checks the Group permissions.
- If neither applies, Linux checks the **Others** permissions.
This means if you configure a directory with chmod 700 (read, write, execute only for the owner), and the owner is set to root, no other user (including the web server) will be able to access it, regardless of what group they belong to.
Summary of Differences
| Feature | Chmod | Chown |
|---|---|---|
| Meaning | Change Mode | Change Owner |
| Focuses on | What actions are allowed | Who owns the asset |
| User Classes | Owner, Group, Others | Single User & Single Group |
| Common Values | 755, 644, 600 | www-data:www-data, root:root |
Frequently Asked Questions
- What is the main difference between chmod and chown?
- chmod (change mode) changes file permissions—specifically what read, write, and execute actions are allowed. chown (change owner) changes file ownership—specifically which user and group own the file.
- Do I need root access to run chmod and chown?
- You can run chmod on any file you own. However, you must use sudo (root access) to run chown to change a file's owner to another user, or to change the ownership of system files.
- Should I run chmod or chown first?
- Generally, you should run chown first to set the correct owner and group (e.g., www-data for web servers), and then use chmod to restrict or grant access levels based on that ownership.