Skip to content
BENIBIX Learn

chmod vs chown

People often mix up chmod and chown because the names are so close. chmod changes what can be done to a file: read, write or run. chown changes who the file belongs to. A permission denied error can need either one, so read ls -l first and see which part is wrong.

Infrastructure⌨️ Linux & the Command Line

chmod

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

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
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.
Full entry
Infrastructure⌨️ Linux & the Command Line

chown

A command that changes which user and group own a file.

chown changes who owns a file or folder. You give it a user, and you can add a group after a colon. Only the root user can give a file away, so you usually run it with sudo. Add -R to change a folder and everything inside it. The owner is the person the first set of rights applies to.

Example
Jack copies a website into place with sudo, so root owns it. The web server cannot write to it until Jack runs chown.
Why it matters
A program can only use files that its user may touch. A wrong owner is a common cause of errors.
Full entry

In one line

chmod
A command that changes who may read, write or run a file.
chown
A command that changes which user and group own a file.