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

  • How to list groups a user belongs to
  • Find files which belong to a specific user
  • Unix user management commands
  • Unix commands

Contact Me

Follow me on Facebook, Twitter or Telegram:
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!

Recent Tweets