How to create sudo user on Ubuntu 18.04 Server
On Ubuntu 18.04 Linux, this article will show you how to create a sudo user. We’ll start by creating a new sudo user via the command line, and then we’ll use Ubuntu’s graphical interface to create a sudo user.
The sudo user has administrative privileges, so he or she can run any command as root.
Take note of the following sign.
# The number sign necessitates the execution of given linux commands with root privileges, either directly as a root user (admin) or via the sudo command.
$ While the dollar sign necessitates the execution of given linux commands as a regular non-privileged user,
Create a sudo user using CLI (Command Line Interface)
We must first create a regular user before we can create a sudo user. The adduser command can be used to accomplish this.
$ sudo adduser netizen
Next, the new user which is netizen must be added to an existing sudo group:
$ sudo usermod -aG sudo netizen
We’ve just made a new sudo user named netizen. We’ll be testing new sudo privileges at this point. To log in as the newly created user, use the su command:
$ su netizen
To run a command as administrator (user “root”), use “sudo “.
See “man sudo_root” for details.
We can now run any command with root privileges using the sudo command by prefixing the actual command with sudo. We can also gain root access using the following command:
$ sudo -i [sudo] password for netizen:
Notice the # character sign. This means we are now logged in as root. To confirm run:
# whoami root