Monday, January 7, 2019

Linux CentOS In-Depth: Creating and Adding Users to The developers Group

In the previous post we created a user called "John Wallace", in this post we are going to add John and Jason into the developers group. In any system you want to group users into groups so that you can easily assign constraints and privileges to a group of user instead of doing it one at a time.

To create a group call developers type in the following command:

su to get root access

groupadd developers to add the group developers

3. Now we want to assign John and Jason to the developers group, with this command useradd john -G developers and repeat the command with jason

As you can see we used the usermod command instead of the useradd command because john, and jason already exists.

4. Now let's assign a group to the user on creation using the useradd command useradd -s /bin/bash -d /home/dora -m dora -G developers

In the command above we added a new user called dora and assigned her to developers group at the same time. The -G option indicates that we want to assign a default group to the user.

5. Now to verify we are going to list the members of the developers group with this command grep 'developers' /etc/group this command searches for entry for the developers group in the /etc/group file

6. Now let's say John is a bad developer and always brings down the server with his infinite loops. We can use this command to remove John from the developers group gpasswd -d john developers