Home / Localhost / chmod and chown

chmod 755 vs 644, chmod +x and chown user:group

What chmod 755 and 644 mean, how to make a script executable with chmod +x, and the exact syntax for chown user:group.

Every file has three sets of permissions: owner, group and others. chmod changes what each set can do, and chown changes who the owner and group are. Numbers add up: read is 4, write is 2 and execute is 1.

Fix a permission problem

  1. Look at the current permissions: ls -l filename.
  2. Make a script runnable: chmod +x script.sh.
  3. Set normal permissions for files and folders (below).
  4. If the owner is wrong, change it with sudo chown user:group filename.

Commands you can copy

Make a script executable
chmod +x script.sh
Typical file: owner can edit, others read
chmod 644 file.txt
Typical folder or program
chmod 755 folder
Private key
chmod 600 ~/.ssh/id_ed25519
Whole folder tree
chmod -R 755 folder
Change owner and group
sudo chown user:group file
Change owner only
sudo chown user file
Change group only
sudo chown :group file
Owner and their login group
sudo chown user: file
Recursive
sudo chown -R user:group folder

How the numbers work

chmod 755
7 for the owner (4+2+1: read, write, execute), 5 for the group (4+1: read, execute), 5 for others. Owners edit, everyone can read and run it. Typical for folders and programs.
chmod 644
6 for the owner (4+2: read, write), 4 for the group and 4 for others (read only). Typical for ordinary files.
The four-digit form
The optional first digit sets setuid (4), setgid (2) and the sticky bit (1). The sticky bit on a folder, as on /tmp, stops users deleting files they do not own.
chmod +x
The symbolic form +x adds execute permission to the existing mode. With no “who” given, it applies to all categories except bits set in your umask. u+x adds it for the owner only.
chmod -R and symlinks
-R works through folders. chmod never changes a symbolic link itself and ignores symlinks it meets during -R.
chown syntax
OWNER:GROUP changes both, with no spaces. OWNER changes only the owner. :GROUP changes only the group. OWNER: sets the owner and their login group. -R recurses and -h affects symlinks themselves.
Permission denied when running a script
The file is missing execute permission: chmod +x. Or the folder above it is not searchable (needs x).
Calculator
Not sure which number you need? Use the chmod calculator.
SSH key rejected
Private keys must not be readable by others. Use chmod 600 and see the SSH config generator.

Questions about chmod and chown

What is the difference between chmod 755 and 644?
755 lets everyone run or enter the item, and only the owner write to it. 644 is read and write for the owner and read-only for everyone else, with no execute.
How do I give a script execute permission?
chmod +x script.sh, then run it with ./script.sh.
What is the chown user:group syntax?
chown user:group file, with a colon and no spaces. Needs root to change the owner.
Is chmod 777 a good idea?
No. It lets every user change the file. Pick the lowest permissions that work.

Updated 2026-10-27

Related pages