How To Create User In Linux

Managing users is one of the most fundamental tasks in any operating system. In Linux, the same holds true. Creating a new user in Linux is a straightforward process that can be done through the command line interface. In this blog post, we will explore the step-by-step process of how to create a user in Linux.

Opening a Terminal

The first step towards creating a new user in Linux is to open a terminal. You can do this by pressing Ctrl + Alt + T on your keyboard, which should open a new terminal window on your desktop.

Switch To Root User

Before we can create a new user, we need to switch to the root user. This is because adding a new user requires administrative privileges. To switch to the root user, type the following command into your terminal and hit enter:

su -

You will be prompted to enter the root password. Once you’ve provided the password, hit enter again. If you entered the password correctly, you should now be logged in as the root user.

Create a New User

To create a new user, we will use the useradd command followed by the name of the user we want to create. For instance, if we want to create a user named ‘john’, we would use the following command:

useradd john

This will create a new user named ‘john’ with all the default settings. If you want to specify a home directory for the user or other options, you can use additional flags with the useradd command. For instance, to create a user named ‘john’ with a home directory in ‘/home/john’, you would use the following command:

useradd -m /home/john john

Set a Password for the New User

After creating a new user, it’s important to set a password for that user. This can be done using the passwd command followed by the username. For instance, to set a password for the newly created ‘john’ user, you would use the following command:

passwd john

You will be prompted to enter a password. Type your desired password and hit enter. You will then be asked to retype the password. Retype the same password and hit enter again. If everything went well, the password for ‘john’ should now be set.

Conclusion

As you can see, creating a new user in Linux is a simple process that can be done in just a few steps. All you need is administrative privileges, a terminal, and a few basic commands. Happy Linux-ing!