Cheatsheet: chmod & chown

Last updated 2026-06-21

Common modes

Set a normal readable file mode

chmod 644 file.txt

Set an executable script or directory mode

chmod 755 script.sh

Make a private key readable only by the owner

chmod 600 ~/.ssh/id_ed25519

Make a directory private to the owner

chmod 700 ~/.ssh

View permissions in long listing format

ls -l file.txt

Symbolic permissions

Add execute permission for the owner

chmod u+x script.sh

Add execute permission for everyone

chmod a+x script.sh

Remove write permission for group and others

chmod go-w file.txt

Set owner permissions exactly to read and write

chmod u=rw file.txt

Copy owner permissions to group

chmod g=u file.txt

Recursive changes and ownership

Change permissions recursively

chmod -R u=rwX,go=rX project/

Change file owner

chown alice file.txt

Change owner and group

chown alice:developers file.txt

Change group only

chown :developers file.txt

Change ownership recursively

chown -R alice:developers project/

Special modes and defaults

Set the setuid bit on an executable

chmod u+s /path/to/program

Set the setgid bit on a directory so new files inherit its group

chmod g+s shared/

Set the sticky bit on a shared directory

chmod +t shared/

Use numeric mode with sticky bit for a shared directory

chmod 1777 shared/

Show the current default permission mask

umask

Set a common default mask for new files and directories

umask 022

See also: