DEV Community

loading...

Create a new sudo user in ubuntu

Md. Morshadun Nur
Hi I'm a full stack developer from Dhaka, Bangladesh. I am passionate PHP developer. I am expert in Laravel Vue js.
・1 min read

What is 'sudo' ?

Actually 'sudo' command provides administrator privileges. When we create a new server it has a default 'root' user. So, here I'm going to create a new user with sudo access.

Step One

Open your terminal and write the following command

root@localhost:~$ adduser [username] 

Enter fullscreen mode Exit fullscreen mode

Alt Text

Step two

Set the password and confirm the password again.
Alt Text

Step three

Now you need to give 'sudo' permission to the newly created user. So, use the usermod command in the terminal. Command is given bellow -

root@localhost:~$ usermod -aG [username] 
Enter fullscreen mode Exit fullscreen mode

Now, the new user added to the sudo group. you can check by this command -

root@localhost:~$ su - [username] 
Enter fullscreen mode Exit fullscreen mode

And run any command with 'sudo' in the terminal -

 username@localhost:~$ sudo apt-get update 
Enter fullscreen mode Exit fullscreen mode

If you want to add sudo to the existing user then just follow the step three.

Thanks for reading <3

Discussion (0)