Privacy Policy
© 2025 linux101.dev

Changing Permissions with `chmod`

The `chmod` command is used to change the permissions of a file or directory. You can use two primary methods: symbolic mode or numeric (octal) mode.

Symbolic Mode

Symbolic mode uses letters to add (`+`), remove (`-`), or set (`=`) permissions.

CharacterDescription
`u`**User** (owner)
`g`**Group**
`o`**Others**
`a`**All** (u, g, and o)

Example: Add execute permission to all

chmod a+x my_script.sh

Adds execute permission (`+x`) for all users (`a`).

Example: Remove write permission from group and others

chmod go-w file.txt

Removes write permission (`-w`) from the group (`g`) and others (`o`).

Numeric (Octal) Mode

Numeric mode uses a three-digit number to represent permissions for the user, group, and others. Each digit is the sum of the permissions you want to grant.

PermissionNumeric Value
**r** (read)`4`
**w** (write)`2`
**x** (execute)`1`

Example: Set read/write for owner, read-only for group/others

chmod 644 file.txt

* User: `r` (4) + `w` (2) = `6`
* Group: `r` (4) = `4`
* Others: `r` (4) = `4`

Example: Set full permissions for owner, read/execute for group/others

chmod 755 my_script.sh

* User: `rwx` (4+2+1) = `7`
* Group: `rx` (4+1) = `5`
* Others: `rx` (4+1) = `5`

Changing Permissions Recursively

Change permissions of a directory and its contents

chmod -R 755 [directory]

The `-R` flag recursively applies the permissions to the directory and all of its contents.