The command has the following structure:
For files:
chown user:group filename
For directories:
chown user:group directoryname
For directories, we change the ownership of the directory BUT not for the files inside it. If we want to change the inside files, we should use the -R
:
chown -R user:group directoryname
Note, that it can work by specifying only the user or only the group:
Only the user:
chown user filename
Only the group:
chown :group filename
Finally, bear in mind that it is possible not to have the permissions to change ownership and you may need to run the command with sudo
:
chown sudo user:group filename