The Simplest Way How To Add User To Group On Linux

How To Add User To Group In Linux

In this article, I am going to share the simplest way how to add user to group on Linux. For some of you, you may think this is going to be a sophisticated task to do. But you will find it the other way around after finishing this post.

It is true that Linux is not as famous or widely used as other platforms. Yet, still, there are many people who use it around the globe. It is due to particular reasons they find that Linux has that cannot be found in the other platforms. One of the reasons that the users say is that Linux is more secure compare to other OS.

One of them is that in Linux many users can connect to it and work altogether at the same time. Therefore, it is important to understand and apply user management properly. Hence, the administrator needs to understand many aspects of user management. One of them is the simplest way how to add user to group in Linux and also how to remove a user from a certain Linux group as part of the user management reason.

Adding A User To A Linux Group

Here, I am dividing two categories of users to be assigned. They are the new user and the already existing user.


For A Newly Created Linux User

The first one is how we can assign a new user to a Linux group. In this case, you can create a new user and directly assign him to a group. For this purpose, you can use the useradd command. Here is how to do it.

useradd -G groupexample(replace with group name) userexample(replace with user name)

This is how it will look when I change the group name and user with a sample name.

useradd -G solvewareplus jason

And you can use the below command to add a password for the user.

psswd jason

The command order will look as below.

"New
New User

For An Existing Linux User

AsĀ  I am sharing an existing user, so before going further I assume that you have ensured that the user is already in the system. To add the user to the Linux group, we are going to use the usermod command followed by -a and -G command. Please see the below command steps carefully.

usermod -a-G groupexample(replace with group name) userexample(replace with user name)

Or, here below is the example when I change the group (change to solvewareplus) and user example (change to jason).

usermod -a-G solvewareplus jason

"Existing
Existing User

Assign User To Multiple Groups

Additionally, enable a user to be included in more than one group. For this purpose, you can also use the usermod command and separate the group names with a comma. This is an example of how you can do it.

usermod -a -G groupA,groupB,groupC userexample

You can change the groupA,groupB,groupC userexample with the actual group name and user name you have. Simple and easy, right?!

Conclusion

As Linux is not as popular as some other platforms, people tend to justify it as difficult to operate. Moreover, the commands to perform for a particular task.

Having read this article, and after having a try on this, I believe this will turn your opinion the other way around. To add a user to a Linux group is as simple as flipping your hand, isn’t it?? Let me know your opinion on the comment box below.



%d bloggers like this: