Root-Server Tutorial

ROOT-SERVER TUTORIAL

How to Create a New User Account in Linux

This tutorial explains all the necessary steps for creating a new user account in Linux using the command line interface.

Author:

Peter Mesiha

Last updated:

19/04/2023

Introduction

Creating a new user account in Linux can be done easily using the command line interface. In this tutorial, we will go through all the steps that are required to create a new user account in Linux.

Requirements

Before starting, you should have the following:

  • Access to a Linux machine with sudo privileges
  • Basic knowledge of the Linux command line interface

Step 1 - Open the terminal

To create a new user account, we need to use the command line interface. Open the terminal by pressing Ctrl+Alt+T on your keyboard or by searching for "Terminal" in the application launcher.

Step 2 - Create a new user account

To create a new user account, we will use the useradd command. The basic syntax of the useradd command is as follows:

sudo useradd username

Replace username with the desired username for the new user account. For example, to create a new user account named john, use the following command:

sudo useradd john

By default, the new user account will not have a password and will not be able to log in to the system. To set a password for the new user account, use the passwd command as follows:

sudo passwd john

Enter and confirm the new password when prompted.

Step 3 - Add user to groups

By default, the new user account will not have any special privileges or permissions. To add the new user account to a specific group, use the usermod command as follows:

sudo usermod -aG groupname username

Replace groupname with the name of the group you want to add the user to, and username with the username of the new user account. For example, to add user john to the sudo group, use the following command:

sudo usermod -aG sudo john

Conclusion

Creating a new user account in Linux is a simple process that can be executed from the command line interface. By following the steps outlined in this tutorial, you can create a new user account and, if desired, grant administrative privileges.

License

MIT

Copyright (c) 2021 netcup

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributor's Certificate of Origin

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or

  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or

  3. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.

Published 19/04/2023 by Peter Mesiha

Submit your tutorial

Get 60€ netcup vouchers for every published tutorial.