Create sudo-capable users on Ubuntu – How it works

Published February 15, 2023


Create sudo-capable users on Ubuntu – How it works

IBy default, the user root is set up when installing Linux. This has all rights to administer the operating system. The other users initially have no administrator privileges. With the sudo command, authorized users can run programs in the root rights. This article explains how to create a sudo-capable user.

Create user

Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Debian 10 and Debian 11
  • Log in as a root user on the desired server.

  • To create a new user, enter the following command:
    [ root @ localhost ~ ] # adduser USER NAME
    Example:
    [ root @ localhost ~ ] # adduser maxmustermann

  • Enter the desired password and repeat it.

  • Optional: Enter additional user information. To skip entering this information, press the Enter key.
    Changing the user information for maxmustermann
    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 ]

  • Enter Y and press the Enter key.

Assign sudo rights to a user

Debian and Ubuntu

To assign sudo rights to a user in Debian and Ubuntu, you must add them to the sudo group. To add the user to this group, enter the following command:
[ root @ localhost ~ ] # usermod -aG sudo USER NAME
example
[ root @ localhost ~ ] # usermod -aG sudo maxmustermann
To check whether the change was successful, enter the following command:
localhost: ~ # groups USER NAME
Example:
localhost: ~ # groups maxmustermann

Buy Cheap Europe Dedicated Server  at $79