2.10.7. Setting User and Group Ownership of Files

Linux for Programmers and Users, Sections 3.31 and 3.32 chown


Change ownership of files (super user only)


chown [-R] newowner FILE... newgrp


Change the shell’s group ID. When you first log into the system, your group ID is set to your default group. Any files or directories that you create will have this group ownership. They can later be changed to belonging to a different group using chgrp. However, if you will begin working on a project where you want to share anything created, it may be simpler to use the newgrp command first, so that all new files and directories will be owned by the specified group.


newgrp group
$ groups
tim cmst270
$ id
uid=500(tim) gid=500(tim) groups=500(tim),537(cmst270)
$ newgrp cmst270
$ id
uid=500(tim) gid=537(cmst270) groups=500(tim),537(cmst270)
$ touch foo1
$ ls -ld foo1
-rw-r--r-- 1 tim cmst270 0 Sep 3 13:57 foo1


newgrp will sometimes prompt for a password. To make it not prompt for a password, the systems administrator must remove the entry for the group from the /etc/gshadow file. chgrp


Change the group ownership of each FILE to GROUP


chgrp [-R] GROUP FILE...
-R, --recursive

operate on files and directories recursively