Changing groups
The chgrp
command will be discussed now in the context of making packtgroup
the new owner of testfile
. After the command, we specify the name of the group and the name of the file whose ownership is to be changed (in this case, testfile
):
sudo chgrp packtgroup testfile
Let’s check the ability of user packtdemo
to write to this file now. A permission refused error should appear for the user. We can set the relevant permissions for the group to allow packtdemo
to write to the file:
sudo chmod g+w testfile
Then use usermod
once more to add the account to packtgroup
, this time using the -aG
combined option as follows:
sudo usermod -aG packtgroup packtdemo
The abbreviation for append to group is -aG
.
Currently, packtgroup
is referred to as a subsidiary or auxiliary group for user packtdemo
. When packtdemo
next logs in, the updated access permissions will be active.
We can use chown
followed by the usernames and filenames, in that order, to...