Hello Techies, as we know that root is the admin user in Linux who has all rights on all commands and files. It is not recommended to use root user to perform administrative tasks but assign administrative privileges to a local user via sudo. An ordinary user who has admin rights is known as ‘sudo user’.
In this post, we will learn how to create a new sudo user on Ubuntu and Debian Linux. Let’s assume we want to create user with name ‘sysops’ name.
Creating Sudo User on Ubuntu Linux
In Ubuntu Linux ‘sudo’ is the group which has all admin rights. This group is already defined in the sudoers file. If we add new or existing user to the sudo group, then that user will automatically inherit admin rights from sudo group. In case of adding new sudo user, first add the user and then add that user to sudo group using adduser and usermod commands respectively. Example is shown below
# adduser sysops
Above command will prompt to set the password and other details.
# usermod -aG sudo sysops
Output of above Command would look like below:
Creating Sudo User on Debian Linux
From Debian 10 and Debian 11 onwards, sudo package is not the part of default OS installation because of that sudo group is not available by default. So, to create a sudo user on Debian 10 / 11, first install sudo package using following apt command.
$ sudo apt update $ sudo apt install -y sudo
Once the sudo package is installed then sudo group and its entry in sudoers file will be populated automatically. Now run the same two commands that we use on Ubuntu Linux,
# adduser sysops # usermod -aG sudo sysops
Test Sudo User
To test sudo user first switch to sudo user from your current user with help su command,
# su – <sudo-username>
# su - sysops
Now run any administrative command by writing sudo in infront of it. Example
$ sudo whoami
If output is ‘root’ then it means user has sudo privileges and can run perform administrative tasks.
Output of above two commands would look below:
Great, above confirms that we have successfully created a sudo user. That’s all from this post, please do post your queries and feedback in below comments section.