Linux has a great feature for users that would like to have some additional security for their home directory setup. This is called “uid” (which is like the “groups”) option which allows a single user to have multiple user accounts under a single home directory. Here is how to set this up for a new user.
In our home directory, run the useradd command like this: useradd –groupid=root –uid=root –newuser You can specify the home directory as per the requirement, we can also specify the user name of the user to be added. When the user name has been specified, the user ID for the new user will be granted. The user name and the home directory can be specified as per the requirement. We can also change the group id if we want the new user to be in a different group from the one that the user is already in. In this case, the group id for the user will not be updated and the security for that group will not be allowed.
For new users who have not installed any application with group privileges, you may either add the user without home directory or set it as group. For instance, to add user as an empty user, run the following command: useradd –groups=empty –uid=empty –groups=empty –groups=home We can see that the useradd command has two alternatives for setting up the user. We can either add the user without home directory or as part of a group. The group id will not be changed in this case. If we check the groups file, we find that the group id is already set up for the new user.
The adduser command can also be used to add a user to a specific group. For example, if we want to create usergroup for our development team, we can add the new user as a member of the team and he will be added as a member of the group also. However, to change the home directory of the user, we can use the standard useradd -type command. For instance, if we want to change the home directory of the newly created user, we can type the following command: useradd –directory=directory –shell=$–groups=directory We can see that the useradd –groups=directory syntax works only with the bash shells. The PHP scripts do not support this command.
To add user to a usergroup, first create a usergroup and then add the new user to this group. However, to set the group id, we can use the standard useradd –id command. For instance, if we want to create a usergroup named greenpepper in our company, we can type the following command: useradd –groups=usergroup –shell=phpmyadmin –uid=administrator We can see that the group id is set up the same way as the userid. Now, if we try to add the user to our group, the following command should be used: useradd –groups=usergroup –shell=phpmyadmin –uid=administrator Finally, if we try to remove a group, the removeuser command should be used. For instance, if we remove the user “administrator” from our company’s group, the removeuser command should be used: useradd –shell=phpmyadmin –groups=usergroup –uid=administrator Now, you know how to add user to a usergroup and how to remove a user from a group. Hope these tips will help you!