How To Create User Accounts in Unix

If you want to quickly create a new user account in your Unix OS, it ca be done with just one line

Adding new user accounts in Unix

To create a basic Unix user account with default settings, you need to know only one thing: the username.

The reason I say it as one word is because username (quite often referred to as "login") is not the actual name of the new person gaining access to your Unix system, but rather a single keyword uniquely identifying this user in your system. Most often, usernames are derived from real names of users – jsmith, johns or smithj for John Smith, just to give you a few examples.

The simplest way to add a new user to your system is to do run a command like this:

ubuntu# useradd jsmith

If you don't get any errors thrown back at you, this means your command was executed successfully and you now have a new user. Use this command to verify:

ubuntu# finger jsmith
Login: jsmith                     Name:
Directory: /home/jsmith                 Shell: /bin/sh
Never logged in.
No mail.
No Plan.

If you attempt to create a user with existing username, you'll obviously get an error:

ubuntu# useradd jsmith
useradd: user jsmith exists

Setting a password for the newly created user account

Once you have created new user, you'll most likely need to have a new password assigned to it. Here's how you do it:

ubuntu# passwd jsmith
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

As you can see from the example, you'll be asked to type the new password twice, and it will be assigned to the user only if both inputs match.

See also:

  • kuba

    The useradd command is not exactly the same in different UNIXEN a.o. Linux flavors. Some time ago I also noticed an "adduser" script ( I think it was Redhat).

    Now let's look at how useradd works in Solaris:

    #useradd -u jack -g other -c "Jack The Ripper" -d /export/home/username -s /bin/ksh -m jack

    -c comment
    -u uid
    -g group
    -d userdir
    -s path to shell
    -m make it

    If you don't specify a group id, Solaris defaults to "other".
    If you don't explicitly specify the home dir, it won't be created.

  • Gleb Reys

    Hi Kuba,

    And thanks for stopping by! I know exactly the script you're talking about, I've seen adduser long time ago too.

    The useradd command is a more recent one, and it's syntax is very close, if not the same, among all the Linux systems and Solaris.

    This is the first post, so I'll be sure to expand on it explaining all the options! Also, since most users who are new to Unix don't know what home directory is anyway, they don't have to specify it – and even though the homedir won't be created, the user entry itself will be added without a problem.

    Thanks for a great comment! Great to know someone's watching, and for more advanced users – great way to learn from comments until I post more.

  • gopal

    ya its really useful to me

  • Pingback: What to do if numeric id is shown instead of Unix username | UNIX Tutorial: Learn UNIX()

  • Dave

    How do you change the owner of all files owned by a user to another user?

  • Gleb Reys
  • sreenivasa murhy raju

    Good example. It helped me in creating the user and assinging the password.


  • ashutosh shukla

    I apply this command on server but this error is then what I do and which type of problem

    useradd jsmith
    sh: useradd: not found.

  • was really helpful

  • bogarvirag

    Do I have to have sudo rights to do that?

  • Amjid

    Try adduser jsmith

  • Amjid


  • Pingback: Running processes in OS X as the logged-in user from outside the user’s account | Der Flounder()