How to change file permissions with chmod - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

How to change file permissions with chmod
=========================================

### [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

Change Linux and macOS file permissions with chmod using symbolic and numeric modes, recursive changes, and why 777 is rarely the answer.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 2 minute read

1. [How Linux permissions work](#content-how-linux-permissions-work)
2. [Symbolic mode](#content-symbolic-mode)
3. [Numeric (octal) mode](#content-numeric-octal-mode)
4. [Recursive changes](#content-recursive-changes)
5. [A word on 777](#content-a-word-on-777)

[\#](#content-how-linux-permissions-work "Permalink")How Linux permissions work
-------------------------------------------------------------------------------

Every file and directory on Linux and macOS has permissions for three groups: the **user** (owner), the **group**, and **others** (everyone else). Each group can have three permissions: **read** (`r`), **write** (`w`), and **execute** (`x`).

Run `ls -l` and you'll see them on the left:

 ```
ls -l
-rw-r--r--  1 jane staff  1240 Jun 23 10:00 notes.txt

```

The first character is the file type (`-` for a file, `d` for a directory). The next nine are three blocks of `rwx`: owner, group, others. Above, the owner can read and write, while group and others can only read.

`chmod` ("change mode") is how you adjust those bits.

[\#](#content-symbolic-mode "Permalink")Symbolic mode
-----------------------------------------------------

Symbolic mode is the readable way to make targeted changes. You name the target (`u` user, `g` group, `o` others, `a` all), then `+`, `-`, or `=`, then the permission.

 ```
chmod u+x deploy.sh    # give the owner execute
chmod g-w report.txt   # remove write from the group
chmod o=r config.ini   # set others to read-only exactly
chmod a+r public.txt   # give everyone read

```

The `+` adds, `-` removes, and `=` sets exactly (clearing anything not listed). This is my go-to when I just need to flip one bit. Making a script runnable is so common I gave it its own write-up: [make a script executable with chmod +x](/make-script-executable-chmod-x).

[\#](#content-numeric-octal-mode "Permalink")Numeric (octal) mode
-----------------------------------------------------------------

Numeric mode sets all three groups at once. Each digit is the sum of read (`4`), write (`2`), and execute (`1`):

- `7` = `rwx` (4+2+1)
- `6` = `rw-` (4+2)
- `5` = `r-x` (4+1)
- `4` = `r--`

The three digits are owner, group, others, in that order:

 ```
chmod 755 deploy.sh    # rwxr-xr-x — owner full, others read+execute
chmod 644 notes.txt    # rw-r--r-- — owner read+write, others read
chmod 600 secret.key   # rw------- — owner only

```

`755` is the standard for scripts and directories; `644` is standard for regular files.

[\#](#content-recursive-changes "Permalink")Recursive changes
-------------------------------------------------------------

To apply a mode to a directory and everything inside it, add `-R`:

 ```
chmod -R 755 ./public

```

Be careful here. Files and directories usually want different permissions (directories need execute to be enterable), so a blanket recursive chmod can break things. When that matters I use `find` to target each type separately:

 ```
find ./public -type d -exec chmod 755 {} \;
find ./public -type f -exec chmod 644 {} \;

```

[\#](#content-a-word-on-777 "Permalink")A word on 777
-----------------------------------------------------

You'll see `chmod 777` suggested as a quick fix all over the internet. It grants read, write, and execute to **everyone**, which is almost never what you want. On a shared server it's a real security risk. If something isn't working, the fix is usually correct ownership (`chown`) or a sensible `644`/`755`, not throwing the doors wide open.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

- [Argument list too long (Bash: /bin/rm)](https://rocketeersapp.com/knowledge/argument-list-too-long)
- [How to install Composer packages locally](https://rocketeersapp.com/knowledge/install-composer-packages-locally)
- [How to send GET and POST requests with curl](https://rocketeersapp.com/knowledge/curl-post-get-api-requests)
- [Essential Linux command line basics for developers](https://rocketeersapp.com/knowledge/linux-command-line-basics)
- [How to search file contents with grep](https://rocketeersapp.com/knowledge/search-files-grep-command)
- [The complete guide to the curl command](https://rocketeersapp.com/knowledge/curl-command-complete-guide)

 [View all 21 articles →](https://rocketeersapp.com/knowledge/command-line)
