Chown
Chown
Chown
or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file. Set the file's owner:
$ chown username:usergroup somefile After giving this command, somefile's new owner would be user username and the group usergroup.
You can set the owner of a directory exactly the same way you set the owner of a file:
As you can see, chown nicely reports to you what it did to each file. < chgrp - change the group ownership of a file > In addition to chown, you can also use the chgrp command to change the group of a file or a directory. You must, again, be either the root user or the owner of the file in order to change the group ownership.
chgrp works pretty much the same way as chown does, except it changes the file's user group instead of the
owner, of course.
$ chgrp usergroup somefile After issuing this command, the file somefile will be owned by a user group usergroup. Although the file's group has changed to usergroup, the file's owner will still be the same.
The options of using chgrp are the same as using chown. So, for example, the -R and -v options will work with it just like they worked with chown:
-Rv usergroup somedir group of 'somedir/' to usergroup group of 'somedir/boringfile' to usergroup group of 'somedir/somefile' to usergroup