Linux add a user using command line tools

by on September 22, 2006 · 23 comments· LAST UPDATED September 25, 2006


Q. How do I add a new user using command line tools? What are command line option recommended.

A. You need to use useradd command, which is responsible for creating a new user or update default new user information

The useradd command creates a new user account using the values specified on the command line and the default values from the system. The new user account will be entered into the system files (/etc/passwd) as needed, the home directory (/home/username) will be created, and initial files copied, depending on the command line options.

Task: Add a user to the system

Syntax is as follows for useradd command:
useradd <username>

By default user account is locaked, you need to setup a new password:
passwd <username>

For example add a new user called tom and set password to jerry:
# adduser tom
# passwd tom

If you want to add a user to group read how to add a user user to group

List of common options:

  • -c comment: Add a comment for the user
  • -d home-directory: Create a new home-directory
  • -e yyyy-mm-dd: Date for the account to be disabled
  • -f days: Number of days after the password expires until the account is disabled. (If 0 is specified, the account is disabled immediately after the password expires. If -1 is specified, the account is not be disabled after the password expires.)
  • -g group-name: Primary Group name or group number for the user's default group (group name must exist)
  • -G group-list: List of secondary additional (other than default) group names or group numbers, separated by commas, of which the user is a member (group name must exist)
  • -m: Create the home directory
  • -M: Do not create the home directory
  • -s: User's login shell (default /bin/bash)

To read all command line option type following command:
$ man adduser

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 23 comments… read them below or add one }

1 maruf February 21, 2009 at 5:38 pm

thanks for your information.


2 digitalpbk May 17, 2009 at 5:45 pm

Thank you
how do you set limits such as disk quota ?


3 bug March 3, 2010 at 8:20 am

For example add a new user called tom and set password to jerry:
# adduser tom
# passwd tom

passwd in example should be:
# passwd jerry


4 BryAnna February 5, 2011 at 12:04 am

Its actually
useradd or adduser tom
passwd tom
The following prompt will come up after you input “passwd tom” than type jerry
New UNIX password: jerry


5 john December 5, 2013 at 8:26 pm

Do you even linux?


6 newbee April 5, 2010 at 3:49 pm

Use the command called ‘quota’ to set limits for disk usage.


7 PANYE June 3, 2010 at 3:03 pm

hi please how can i change the acces pasword the ftp server ton enter in my server ebrunie-voip?
i wont to change the access to protect my server agains some fraud.


8 An M June 26, 2010 at 2:30 am

i was looking for differences between ‘useradd’ and ‘adduser’, but you seem to mix both….

see this:you first talk about useradd, then you put an example with adduser !


9 Annie June 24, 2011 at 10:45 am

How can i manage user from Command Line

Let suppose i create user spiderman and grant Superuser like root!


10 Mangesh September 19, 2011 at 7:54 am

Is it possible to create user and password in single cmd?

useradd -m user1 -p passwordforuser1


11 G8KeaPoR December 22, 2011 at 4:28 pm

Be sure to man useradd as there are a bunch of other options that this article leaves out like adding keys, names, passwords, and other things. man is your friend learn to use it or you will hate life in linux/unix


12 Falcon November 3, 2012 at 8:58 pm

I am still a bit new to UNIX but yours sounds like probably the best advice here… about man most definitely.

On a side note… and this is just a shot in the dark. I am trying to get an Ubuntu 10.04 box, which has been upgraded and updated as of 11/2012, to run Teamspeak and a game called ArmA 2. The game has a modification called @ACRE that enhances Teamspeak. I have the Teamspeak server running and can get to it through my WAN IP. I have the mod loaded in the game server. I have the same mod loaded in the Windows client. The Teamspeak server never recognizes the the mod is loaded in the game.

Again, I know this is a shot in the dark but maybe you know about this game or maybe you have some general suggestions.

Anyway, thanks again for the good advice.


13 Teng Yang February 1, 2012 at 7:13 pm

What would you type at a command line to create a new user called “Susan”, but not create a password? (Susan will not be able to use her account until you set one)


14 Omi April 25, 2012 at 2:39 pm

Hello, thanks for the information, but the real question is if u want to create or give an user admin rights or root rights how do you do it…. ?


15 Uday May 29, 2012 at 7:18 am

thanks for giving the information about useradd but how do we can make user as a group


16 Ace Macleod July 19, 2012 at 2:51 pm

I know I’m late to the party but to allow a user to run root commands,
you can do a couple things…

A) add the user’s numeric If to the root group in /etc/group
This is a single file but it doesn’t guarantee all root access.

B) add them to the /etc/sudoers file.

You need to be root to do it.
su as root, change the permissions on /etc/sudoers to 600 then vi/nano it. After looking through the file to see the format you need to use to add the user, save the file, change the perms back to 400 (I think it was 400) otherwise sudo won’t work for the user.

Now whenever you log in as that user, you can type in sudo and you’ll have root permissions.

Easy as Pi
– Ace Macleod -


17 liang November 2, 2012 at 8:55 am

hi ,
how about add user full name


18 nithya December 17, 2012 at 9:04 am

how to create mail id for a particular user in putty server? and already i had added user name and password,after that how to proceed?


19 sameer May 10, 2013 at 8:42 am

WoW ! nice article i got it here. Thanks for sharing this information on your blog.


20 Sham kiran December 2, 2013 at 4:59 am

The command used to send the message to all users who logged or not logged in.


21 tamnq February 28, 2014 at 10:57 pm

how to su user basic to root permision


22 Andrei March 24, 2014 at 11:30 pm

Hmm… this appears simple, but for me it’s not working. I tried it like this:

adduser -d

But it doesn’t create anything, just lists the option. Trying to set a password confirms the username doesn’t exist. I’m a total n00b, basically just following a tutorial for installing Arch, so any ideas ?


23 name March 20, 2015 at 1:15 pm

You should explain the difference between useradd and adduser when you use both…

useradd is the system binary, adduser is a Perl script that simplifies some things.


Leave a Comment

Tagged as:

Previous Faq:

Next Faq: