In some examples, I saw that some used chown
instead of chmod
. I do not know where to use chmod
and chown
. Please explain to me the difference between them, when and why I should use either.
Ubuntu – the main difference between chmod and chown
chmodchowncommand linepermissionsusers
Related Question
- Ubuntu – What’s is the difference between “>” and “>>” in shell command
- Ubuntu – What Is The Difference Between “root”, “user”, “group”
- Ubuntu – What’s the difference between the TTY and the GNOME terminal
- Ubuntu – chown – Difference between user and user:user
- Ubuntu – the difference between “chmod +x” and “chmod 755”
- Ubuntu – www-data related: What’s the difference between these usages of CHOWN
Best Answer
Let's create a file
Let's have a look at the file's metadata
The first part of the information is the file type (
-
at the beginning means it's a regular file) and the permission bitsAfter that we see the owner (zanna) and the group (zanna). We can use the
chown
command to change those:And we use
chmod
to change the permission bitsSince the permission bits are set separately for owner, group and others, you can control file permissions for different users by combining
chown
andchmod
. See this short guide for a crash course on permissions in Linux.