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.
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.
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.
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.