The Complete Guide to “useradd” Command in Linux – 15 Practical Examples

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

99 Responses

  1. pramod says:

    Hi Sir,

    I have a one question..

    How to create a user with custom primary group and then add this user to secondary group in one command, this question asked in interview .

    ex: username – techmint
    primary group name – linux
    secondary group name – admin

    • Ravi Saive says:


      Use following command add a new user to primary group (-g option) and secondary group (-G option).

      # useradd -g linux -G admin techmint
  2. Md. Saidur Rahman says:

    Thank you. Why you used ‘-m -d‘? Can we use ‘-d’ instead of ‘-m -d‘?

  3. Adam Mulla says:

    Hi, I am new for learning Linux from basic to advanced level I think your blog is best to everyone to learn thanks for providing such a great tutorial and articles.

  4. Sohan says:

    How to Prevent reuse of UID/GID in SUSE Linux?

  5. Andrea says:

    The result does not match search criteria right?

    [[email protected] ~]# cat /etc/passwd | grep tecmint

    • Ravi Saive says:


      Yes, search criteria for user ‘tecmint’ was wrong, but thanks for pointing out, we’ve corrected in the writeup..

  6. Sree says:

    I am adding a user “sudo useradd test” in RHEL. I am getting “configuration error – unknown item ‘TMOUT=600;’ (notify administrator)”. But user is getting created. However when I try to login I am unable to login ad test. Any idea why so?

  7. Manuel Malagon says:

    I tried using ‘useradd,’ and no home folder was created, also, when trying to switch from ‘root’ to the new user created, I got the message “No directory, logging in with HOME=/.”

    It worked fine until I used ‘adduser’ instead of ‘useradd’. This way the /home/user1 folder was created, and I was able to switch from ‘root’ to ‘user1’ using ‘su – user1’ command.

    After all, ‘useradd’ and ‘adduser’ are not as similar as one would think.

    • Nitrofx says:

      Excellent suggestion. I had the exact same issue. This article needs to be modified to reflect this issue. The commands are not the same and they perform different functions.

  8. faiqkhan says:

    Very helping article sir please continuous to upload some information about permission on file

  9. Daniel says:

    Is it possible to have an account that has no shell, not a root account and it has sftp access by using winscp? I’m setting up a linux box with Litespeed so I would like to have a locked down account that only used for uploading and running the server service.

  10. James Tobin says:

    @Ravi Saive: I suggest you add the command to remove user

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.