$ chown alice file.txt # Change owner to alice
chgrp developers file.txt # Change group to developers
chown alice:developers file.txt # Change both at once
chown alice file.txt # Change owner to alice
chgrp developers file.txt # Change group to developers
chown alice:developers file.txt # Change both at once
chown alice file.txt # Change owner to alice
chgrp developers file.txt # Change group to developers
chown alice:developers file.txt # Change both at once
- rwx r-x r-x
│ │ │ │
│ │ │ └── Others: read + execute (no write)
│ │ └────── Group: read + execute (no write)
│ └────────── Owner: read + write + execute
└──────────── File type (- = file, d = directory, l = symlink)
- rwx r-x r-x
│ │ │ │
│ │ │ └── Others: read + execute (no write)
│ │ └────── Group: read + execute (no write)
│ └────────── Owner: read + write + execute
└──────────── File type (- = file, d = directory, l = symlink)
- rwx r-x r-x
│ │ │ │
│ │ │ └── Others: read + execute (no write)
│ │ └────── Group: read + execute (no write)
│ └────────── Owner: read + write + execute
└──────────── File type (- = file, d = directory, l = symlink)
chmod u+x script.sh # Add execute for owner
chmod go-w config.json # Remove write from group and others
chmod a+r README.md # Add read for all users
chmod u=rwx,g=rx,o=r file # Set exact permissions
chmod u+x script.sh # Add execute for owner
chmod go-w config.json # Remove write from group and others
chmod a+r README.md # Add read for all users
chmod u=rwx,g=rx,o=r file # Set exact permissions
chmod u+x script.sh # Add execute for owner
chmod go-w config.json # Remove write from group and others
chmod a+r README.md # Add read for all users
chmod u=rwx,g=rx,o=r file # Set exact permissions
chmod 644 file
chmod +x script.sh
chmod 755 script.sh
chmod 755 /var/www/html
chmod 755 script.sh
chmod 755 /var/www/html
chmod 755 script.sh
chmod 755 /var/www/html
chmod 644 index.html
chmod 644 config.json
chmod 644 index.html
chmod 644 config.json
chmod 644 index.html
chmod 644 config.json
chmod 600 .env
chmod 600 credentials.json
chmod 600 .env
chmod 600 credentials.json
chmod 600 .env
chmod 600 credentials.json
chmod 400 ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
chmod 700 ~/.ssh
chmod 700 ~/private
chmod 700 ~/.ssh
chmod 700 ~/private
chmod 700 ~/.ssh
chmod 700 ~/private
chmod 750 /var/www/project
chgrp developers /var/www/project
chmod 750 /var/www/project
chgrp developers /var/www/project
chmod 750 /var/www/project
chgrp developers /var/www/project
chmod 755 file.sh # Set exact permissions
chmod -R 644 ./docs # Recursive (all files in docs/)
chmod 755 file.sh # Set exact permissions
chmod -R 644 ./docs # Recursive (all files in docs/)
chmod 755 file.sh # Set exact permissions
chmod -R 644 ./docs # Recursive (all files in docs/)
chmod +x script.sh # Add execute for everyone
chmod u+w file.txt # Add write for owner
chmod go-w file.txt # Remove write for group and others
chmod a+r file.txt # Add read for all (a = all)
chmod u=rwx,go=rx dir # Set exact: owner=rwx, group+others=rx
chmod +x script.sh # Add execute for everyone
chmod u+w file.txt # Add write for owner
chmod go-w file.txt # Remove write for group and others
chmod a+r file.txt # Add read for all (a = all)
chmod u=rwx,go=rx dir # Set exact: owner=rwx, group+others=rx
chmod +x script.sh # Add execute for everyone
chmod u+w file.txt # Add write for owner
chmod go-w file.txt # Remove write for group and others
chmod a+r file.txt # Add read for all (a = all)
chmod u=rwx,go=rx dir # Set exact: owner=rwx, group+others=rx
--reference=FILE
chmod --reference=known-good.conf new.conf # Match permissions from another file
chmod -Rv 755 /var/www/html/ # Recursive with verbose output
chmod --reference=known-good.conf new.conf # Match permissions from another file
chmod -Rv 755 /var/www/html/ # Recursive with verbose output
chmod --reference=known-good.conf new.conf # Match permissions from another file
chmod -Rv 755 /var/www/html/ # Recursive with verbose output
/etc/shadow
chmod 4755 /usr/bin/passwd
# ls -la shows: -rwsr-xr-x
chmod 4755 /usr/bin/passwd
# ls -la shows: -rwsr-xr-x
chmod 4755 /usr/bin/passwd
# ls -la shows: -rwsr-xr-x
# Set setgid on a shared directory
chmod 2775 /var/www/shared
chgrp webdevs /var/www/shared # Now any file created inside /var/www/shared
# automatically belongs to the "webdevs" group
# Set setgid on a shared directory
chmod 2775 /var/www/shared
chgrp webdevs /var/www/shared # Now any file created inside /var/www/shared
# automatically belongs to the "webdevs" group
# Set setgid on a shared directory
chmod 2775 /var/www/shared
chgrp webdevs /var/www/shared # Now any file created inside /var/www/shared
# automatically belongs to the "webdevs" group
# ls -la shows: drwxrwsr-x
# Note the 's' in the group execute position
# ls -la shows: drwxrwsr-x
# Note the 's' in the group execute position
# ls -la shows: drwxrwsr-x
# Note the 's' in the group execute position
chmod 1777 /tmp
# ls -la shows: drwxrwxrwt
# Note the 't' in the others execute position
chmod 1777 /tmp
# ls -la shows: drwxrwxrwt
# Note the 't' in the others execute position
chmod 1777 /tmp
# ls -la shows: drwxrwxrwt
# Note the 't' in the others execute position
chmod 4755 file # setuid + rwxr-xr-x
chmod 2755 dir # setgid + rwxr-xr-x
chmod 1777 dir # sticky + rwxrwxrwx
chmod 6755 file # setuid + setgid + rwxr-xr-x
chmod 4755 file # setuid + rwxr-xr-x
chmod 2755 dir # setgid + rwxr-xr-x
chmod 1777 dir # sticky + rwxrwxrwx
chmod 6755 file # setuid + setgid + rwxr-xr-x
chmod 4755 file # setuid + rwxr-xr-x
chmod 2755 dir # setgid + rwxr-xr-x
chmod 1777 dir # sticky + rwxrwxrwx
chmod 6755 file # setuid + setgid + rwxr-xr-x
chmod 755 filename
~/.ssh/authorized_keys
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/config
chmod -R 755 .
# Directories: 755 (need execute for cd)
find . -type d -exec chmod 755 {} \; # Files: 644 (don't need execute)
find . -type f -exec chmod 644 {} \;
# Directories: 755 (need execute for cd)
find . -type d -exec chmod 755 {} \; # Files: 644 (don't need execute)
find . -type f -exec chmod 644 {} \;
# Directories: 755 (need execute for cd)
find . -type d -exec chmod 755 {} \; # Files: 644 (don't need execute)
find . -type f -exec chmod 644 {} \;
chgrp -R developers /var/www/project
chmod -R 775 /var/www/project
chgrp -R developers /var/www/project
chmod -R 775 /var/www/project
chgrp -R developers /var/www/project
chmod -R 775 /var/www/project
umask # Show current umask
umask 022 # Set standard umask (files: 644, dirs: 755)
umask 077 # Set restrictive umask (files: 600, dirs: 700)
umask # Show current umask
umask 022 # Set standard umask (files: 644, dirs: 755)
umask 077 # Set restrictive umask (files: 600, dirs: 700)
umask # Show current umask
umask 022 # Set standard umask (files: 644, dirs: 755)
umask 077 # Set restrictive umask (files: 600, dirs: 700)
# Create a group for the project
-weight: 600;">sudo groupadd webdevs # Add users to the group
-weight: 600;">sudo usermod -aG webdevs alice
-weight: 600;">sudo usermod -aG webdevs bob # Set the directory group and permissions
chgrp -R webdevs /var/www/project
chmod -R 2775 /var/www/project # setgid ensures new files inherit group
# Create a group for the project
-weight: 600;">sudo groupadd webdevs # Add users to the group
-weight: 600;">sudo usermod -aG webdevs alice
-weight: 600;">sudo usermod -aG webdevs bob # Set the directory group and permissions
chgrp -R webdevs /var/www/project
chmod -R 2775 /var/www/project # setgid ensures new files inherit group
# Create a group for the project
-weight: 600;">sudo groupadd webdevs # Add users to the group
-weight: 600;">sudo usermod -aG webdevs alice
-weight: 600;">sudo usermod -aG webdevs bob # Set the directory group and permissions
chgrp -R webdevs /var/www/project
chmod -R 2775 /var/www/project # setgid ensures new files inherit group
ls -la /path/to/file
namei -l /path/to/file
getfacl /path/to/file
chmod +x filename
chmod u+x filename
#!/bin/bash
ls -la filename
stat filename
chmod --reference=similar_file broken_file - Owner (u) — the user who owns the file. By default, the user who creates a file becomes its owner.
- Group (g) — users in the file's group. Every file is assigned to one group, and any user who is a member of that group gets these permissions.
- Others (o) — everyone else on the system who is neither the owner nor in the file's group. - Read (r = 4) — view file contents, list directory contents
- Write (w = 2) — modify file, create/delete files in directory
- Execute (x = 1) — run file as program, access directory (cd into it) - - — regular file
- d — directory
- l — symbolic link
- c — character device
- b — block device
- p — named pipe (FIFO) - r = 4, w = 2, x = 1
- Add them up: rwx = 4+2+1 = 7
- r-x = 4+0+1 = 5
- r-- = 4+0+0 = 4
- -w- = 0+2+0 = 2
- --x = 0+0+1 = 1
- --- = 0+0+0 = 0 - + — add the specified permission
- - — -weight: 500;">remove the specified permission
- = — set permissions exactly (removes anything not listed) - u — owner (user)
- a — all (equivalent to ugo) - -R — apply recursively to all files and subdirectories
- -v — verbose mode, shows each file being changed
- -c — like verbose but only shows files that actually changed
- --reference=FILE — copy permissions from another file - Read on directory = list contents (ls)
- Write on directory = create/delete files inside it
- Execute on directory = access directory (cd into it, access files by path) - Open the tool — Navigate to DevToolkit Chmod Calculator in your browser.
- Toggle permission checkboxes — Click the read, write, and execute checkboxes for Owner, Group, and Others. Each click immediately updates the octal value and the symbolic representation.
- Or type an octal number — If you already have a permission number like 644, type it in the octal input field. The checkboxes and symbolic notation -weight: 500;">update automatically.
- Review the generated command — The tool generates the full chmod command (e.g., chmod 755 filename) ready to copy.
- Copy to clipboard — Click the copy button and paste the command directly into your terminal. - Web root directory: 755 (owner: deploy user, group: www-data)
- PHP/Python/application files: 644
- Upload directories: 775 (so the web server group can write)
- Configuration files with secrets: 640 or 600
- Log files: 640
- Never use 777 on production servers - ~/.ssh/ directory: 700
- ~/.ssh/authorized_keys: 600
- ~/.ssh/id_rsa (private key): 400
- ~/.ssh/id_rsa.pub (public key): 644
- ~/.ssh/config: 600 - .env files: 600
- API key files: 600
- TLS/SSL certificates: 644 (public cert) or 600 (private key)
- Database credential files: 600 - If a web server needs to read a file: 644 and make sure the web server user owns it (or is in the group)
- If a script needs to be executable: 755
- If only your user needs access: 600 or 700 - Check the file permissions: ls -la /path/to/file
- Check who you are: whoami and id
- Check directory permissions: You need execute on every directory in the path. Run namei -l /path/to/file to see permissions on each component.
- Check for ACLs: getfacl /path/to/file — Access Control Lists can override basic permissions.
- Check SELinux/AppArmor: On systems with mandatory access control, regular permissions might not be enough. Check ls -Z for SELinux contexts. - Chmod Calculator — Visually set and convert file permissions
- Cron Expression Generator — Build cron schedules for automated scripts (see our cron cheat sheet)
- Regex Tester — Test patterns for log parsing and file matching (see our regex cheat sheet)
- Hash Generator — Generate MD5, SHA-256, and other hashes for file integrity checks
- Password Generator — Create strong passwords for system accounts
- Base64 Encoder/Decoder — Encode credentials and certificates (learn more in our Base64 guide)
- JSON Formatter — Format and validate server configuration files