Tux-bigIn Linux,with just few commands you can easily create a new user though command line.In this article I will help you to create a new user and will add the user to new user group.

To create a new User Group

You can use the command groupadd to create a new user group

$ groupadd bloggers

Now lets see how create a new user and add him to this group

To create new User

To create a new user we are going to use useradd command,Lets create a new user with username vivek

$ useradd vivek

Now you can attach other information with this user like User description,Use group and User expiry date.

  • -c : To add description about the user
  • -e : To set expiry date to the user in the format of mm/dd/yy
  •  -g : To add user to existing group

For example

$ useradd -c “Blogger and Writer” -g bloggers -e “ 12/24/13 vivek

Now Lets add a new password to the user

$ passwd vivek
Changing password for user vivek.
New UNIX password:

Visit here to read in detail article about changing user password in Linux

If the user is already created then you will get an error if you use useradd command

$useradd -g bloggers vivek
useradd: user vivek exists

We need to use the command usermod in this case

$usermod -g bloggers vivek

Now to verify whether user was successful added,Execute the following command

$ id vivek
uid=501(vivek) gid=510(bloggers) groups=511(bloggers)

Hope you find this article useful,Tell us about topics that you want to be covered by us.You can use the comment form below.