Linux Permissions and Links Cheat Sheet

Change permissions, ownership, umask, and symbolic or hard links on Linux.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## chmod Basics
Add execute permission for user
chmod u+x script.sh

# Grant user execute permission.

Set file to 644
chmod 644 config.ini

# Common mode for normal text or config files.

Set file or directory to 755
chmod 755 deploy.sh

# Common executable/script or directory mode.

Change permissions recursively
chmod -R u=rwX,go=rX project

# Apply mode changes to a directory tree.

## Ownership and umask
Change owner and group
sudo chown alice:developers app.log

# Set file owner and group together.

Recursively change ownership
sudo chown -R www-data:www-data /var/www/app

# Update owner and group across a tree.

Change group
chgrp developers shared.txt

# Set a file's group without changing owner.

Show and set umask
umask && umask 027

# Inspect and change default permission mask.

## Special Permission Bits
Set setuid bit
chmod u+s binary

# Set executable to run with owner's effective UID.

Set setgid on directory
chmod g+s shared-dir

# New files inherit directory group.

Set sticky bit on directory
chmod +t /shared/tmp

# Allow only owners/root to delete their own files.

More in Linux Permissions and Links

No other published sheets yet.

Recommended next

No recommendations yet.