Tech Junkie Blog: Linux CentOS In-Depth: Adding A New User With useradd and usermod Command

Wednesday, August 15, 2018

Linux CentOS In-Depth: Adding A New User With useradd and usermod Command

One of the most common task you have to do as a Linux administrator is to add a new user.  Especially developers who always wants root access.  To accomplish this task you can use the useradd command in the Terminal session.  Follow the steps below to add a new user to CentOS.

1.  Switch into the root user using su - command

 2. Type the following command useradd -s  /bin/bash -d /home/john -m john then press "Enter"

useradd is the command to add a new user to CentOS, below is an explaination of what each switch means in the command above

-s --shell SHELL - the login shell of the new account, which is the/bin/bash shell
-d --home-dir HOME_DIR - home directory of the new account, which is /home/john

3.  Type ls /home to list the content of the /home directory and you will see the john directory has been created for the user john

4.  We've created a new user name john, but he has no password, to set a password for john we can use the passwd command.  Type the following command to assign john a password passwd john  type in john's password when prompted with New Password:   and confirm the password when prompted with Retype new password:

5.  Even though john has a login, we still don't know what John's full name is to assign a real name to the login john we can use the usermod -c command to assign the login name john a real name

the command above usermod -c "John Wallace" john assigns the name John Wallace to the user name john


  1. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.


  2. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune
    Data science training in kalyan nagar

  3. When I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.

    Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR, Chennai

    Amazon Web Services Training in Tambaram, Chennai|Best AWS Training in Tambaram, Chennai

  4. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    python training in pune
    python training institute in chennai
    python training in Bangalore

  5. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai