Linuxlab

chmod command in Linux: file permissions (755, 644, rwx)

Updated July 3, 2026

The chmod command changes a file's permissions: who can read, write, and execute it.

Syntax

chmod mode file

You set the mode two ways: symbolic (u+x) or an octal number (755).

Common cases

chmod +x script.sh     # make a file executable
chmod 644 file.txt     # rw-r--r--: owner writes, others read
chmod 755 script.sh    # rwxr-xr-x: owner all, others read and run
chmod -R 755 public/   # recursively for a directory and everything in it

How it works: where the numbers come from

A file has three permission groups: owner, group, others. Each has three bits: read r = 4, write w = 2, execute x = 1. A digit in the mode is their sum: 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--. So 755 means rwxr-xr-x and 644 means rw-r--r--. Files are usually 644, directories and scripts 755. The 777 mode opens write access to everyone and is almost always a security hole.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand. The container is deleted when you leave, so there is nothing to be afraid of breaking.

Where this is in the book: the chapter Users, groups, permissions.