Linux Terminal Command: chmod

The chmod command is an essential tool in User & Permission Management. In this tutorial, we will explore what chmod does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The chmod command sets file system permissions (read, write, execute) for the Owner (u), Group (g), and Others (o). Permissions are defined using octal numbers or symbols.


Common Options & Syntax

chmod [options] [arguments]

Here are the most common flags used with chmod:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
chmod +x script.sh

What it does: Adds execute permissions to ‘script.sh’ for all users.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
chmod 755 config/ && chmod 644 config/*.conf

What it does: Sets directory permissions to 755 (Owner rwx, Group/Others r-x) and config files to 644 (Owner rw-, Group/Others r–).


⚙️ Warning & Common Pitfalls

[!WARNING] Do not set files to 777 permissions (read, write, execute for everyone) as a quick fix for permission issues. It poses a severe security risk.


Here are some related posts on cli_tty1 you might want to check out: