2.10.7. Setting User and Group Ownership of Files

Linux for Programmers and Users, Sections 3.31 and 3.32

2.10.7.1. chown

chown

Change ownership of files (super user only)

SYNOPSIS

chown [-R] newowner FILE...

2.10.7.2. newgrp

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.

SYNOPSIS

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

Note

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.

2.10.7.3. chgrp

chgrp

Change the group ownership of each FILE to GROUP

SYNOPSIS

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

operate on files and directories recursively