• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Create a Sudo User on Debian

Written by Admin, Updated On May 7, 2019
debian, sudo, sudo user
How To Create a Sudo User on Debian

In linux sudo is masterpiece to allow users to execute commands with another user’s privileges, default is root user. In this tutorial, you will learn how to create a new user on Debian system and make sudo user by giving it sudo access.

By sudo user account you can execute administrative commands without a need to log in to root user account on your Debian server.

Create a sudo user#

Following are the steps to create a new user and give sudo access to it. You can skip create user steps if you wants to give sudo access to existing user.

First, Login to your server as root user.

ssh root@server_ip_address

Create a new user account using adduser command. Replace demouser with your desired user name:

adduser demouser

It will prompt you to set new password and retype user password. It’s recommended to set a strong password with combination of alphanumeric and special characters.

Adding user `demouser' ...
Adding new group `demouser' (1001) ...
Adding new user `demouser' (1001) with group `demouser' ...
Creating home directory `/home/demouser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Once your password is updated successfully it will make a directory for a new user and make copy necessary configuration files. After that it will ask you to enter new user’s information. These are optional so if you don’t want to enter you can just skip by press Enter for each to set default.

Changing the user information for demouser
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

Now, user is created and we will add new user to sudo group to grant sudo access. By default, members of the group sudo have sudo access on Debian systems.

usermod -aG sudo demouser

Verify sudo access#

Login using new created user or you can switch to the new created user by type :

su - demouser

Use the sudo command to run the whoami command:

sudo whoami

If new user account have sudo access then output of given command will be root as below :

Output
root

Now you can use sudo by just type sudo before any command and give space :

sudo ls -la /root

First time it will prompt you to enter user password for that session :

Output
[sudo] password for demouser:

Conclusion#

You have learned how to create a user with sudo privileges. You can now log in to your Debian server with this user account and use sudo to run administrative commands.

If you have any questions or suggestions, feel free to leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Secure Apache with Let’s Encrypt on Debian 9
Next Article   How to Set Up Apache Virtual Hosts on Debian 9

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install and Use Docker on Debian 11

    How to Install and Use Docker on Debian 11

    March 10, 2023
  • How to Install MariaDB on Debian 11 Bullseye

    How to Install MariaDB on Debian 11 Bullseye

    March 8, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook