chmod changes what the owner, the group and the others can do. chown changes who the owner and the group are.
sudo chownananew owner:staffnew grouprota.txtthe file
| Line | Changes |
|---|---|
sudo chown ana:staff rota.txt | The owner and the group |
sudo chown ana rota.txt | Only the owner |
chgrp staff rota.txt | Only the group |
sudo chown -R till:till /srv/till | A directory and everything under it |
Who may do it
| Change | Who can do it |
|---|---|
| The owner | Only root |
| The group, to a group that you are in, on your own file | The owner |
| The group, to any group | Root |
Without root, a change of owner fails:
text
learner@tidepool:~$ chown ana notes.txt
chown: changing ownership of 'notes.txt': Operation not permittedCheck the result
text
learner@tidepool:~$ stat -c '%U %G %n' /srv/shop/rota.txt
ana staff /srv/shop/rota.txt