Skip to content
BENIBIX Learn

chmod

Infrastructure⌨️ Linux & the Command LineUsers and Permissions

Also known as chmod Command, Change Mode, chmod 755, chmod 600

A command that changes who may read, write or run a file.

Think of it like

Think of it like changing who is on the list for a club. The door stays the same, the list changes.

Example

Emma's private key file is open to everyone, and SSH refuses to use it. She runs chmod 600 on it, and SSH works.

Why it matters

Secret files need tight rights, and scripts need the run right. chmod sets both.

Definition

chmod is the command that changes the permissions on a file or folder. You can give it three digits, one for the owner, the group and others. In each digit, 4 is read, 2 is write and 1 is run, added up. So 7 is all three and 6 is read and write. chmod 600 means only the owner may read and write the file.

Example code

console
$ chmod 600 key.txt
$ ls -l key.txt
-rw------- 1 emma emma 3381 Nov 16 14:02 key.txt
After chmod 600, only Emma may read or change the file.
Each set of three letters turns into one digit. rwx is 7, r-x is 5 and --- is 0.

Common mistake

Using chmod 777 to make an error go away. It hides the real problem and opens the file to everyone.

Key takeaways

  1. 1
    4, 2, 1. Read, write and run, added up.
  2. 2
    Three digits. Owner, group, then others.
  3. 3
    600 for secrets. Only the owner may read it.

Compare

Learn it properly