Creating user in Linux machine or Servers

All the users of a machine should have their own credentials. Using or sharing credentials to each other is not secured or best practice. It will become difficult or may not know who did what.

Image Credit

Linux has multi user option, where literally you can create n number of users with credentials for each user. You can even assign permission to user as what they could do in the system. We can restrict them to just view few files or execute only few commands. Also it will be easy to track all the system events as which user executed what commands and stuffs.

To add user, you can use either adduser command or useradd command.

Note: Only user with sudo privilege can create users in Linux

To add a user —

  1. Login to the machine in which you need to create user.
  2. Switch to root user (sudo -i)
  3. useradd {username} Ex: useradd medium
  4. You are done

In some systems like Debian or Ubuntu on useradd, may ask for first name, last name, address and other stuffs and to set password. If useradd did not prompt to set password, follow below steps:

  1. Switch to new user by su username
  2. type — passwd
  3. It’ll prompt to enter password.

Now basically, it’s done. Now, user can login to the system by using the username and password. Also if the machine has ssh server installed, the user can remotely access the site using the provided username and password.

I’ll post another article stating, how to enable remote access in a machine.

Start-up and tech enthusiast. I write about Tech, Devops and anything related.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store