Create New User with Sudo Privileges using Command-Line

There are multiple ways to create new users in the Linux system. One is well-known GUI-based, where you can directly create new users as Windows users do. But Linux folks are quite different species. They do things that ordinary people avoid doing using a command line.

Requirements

There is not a lot to ask, only Linux operating system, command-line, and of course, your time.

Step 1

Open your Terminal where it’s Console, Konsole, or Terminator. Then make sure you are sudo user. Yes, To create another user, you need to be a root user or sudo user full privileges.

Step 2

Now we will take the help of adduser the command lets us create an account that asks for user details like Password, Full Name, Room Number, Work Number, Home Number, Other in the beginning. So, we don’t have to provide it afterward.

$ adduser [NEW USER NAME]

For fast account, creation go with useradd which create your new user without asking password and other details.

Step 3

Once an account is created, you can easily switch between your current and new users via the command line.

$ sudo su [NEW USER NAME]

To switch between the new user change above [NEW USER NAME] with your new username and go back to your current user type exit in the command shell.

Step 4

Giving sudo privileges to your new user is sometimes very helpful. In Linux, we have another command. usermod This helps us add a new user into sudo group through we get complete access to the system.

$ sudo usermod -aG sudo [NEW USER NAME]

-a: Meaning we are going to append one with another.

-G: Means one will be the account and another will be the group. We will append [NEW USER NAME] to a sudo group.

Step 5

If you want to delete your new user now or in the future, take the use of built-in command userdel. Specify userdel with the username which you want to delete.

$ sudo userdel [NEW USER NAME]

Final Thought

It’s a simple article on creating a new user account with sudo privileges—there is a lot of stuff that is already covered or covered in the coming days.

If you have any issues while creating, let us know in the comment section.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments