Deprecated: File class-phpmailer.php is deprecated since version 5.5.0! Use wp-includes/PHPMailer/PHPMailer.php instead. The PHPMailer class has been moved to wp-includes/PHPMailer subdirectory and now uses the PHPMailer\PHPMailer namespace. in /var/www/wordpress/wp-includes/functions.php on line 6085

Deprecated: Creation of dynamic property WordPress_Module::$redirects is deprecated in /var/www/wordpress/wp-content/plugins/redirection/modules/wordpress.php on line 141
Linux - How To Create a Sudo User - The Grok Shop
Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/wordpress/wp-content/plugins/wordpress-seo/frontend/schema/class-schema.php on line 119

Warning: Trying to access array offset on value of type bool in /var/www/wordpress/wp-content/plugins/social-pug/inc/functions.php on line 597

Linux – How To Create a Sudo User

For admin work, using a non-root user with super-user privileges is good practice.  This user has to be created.  Let’s see how its done with an example on Debian 9:

First we SSH into our target machine:

$ ssh root@grokshop.tv
Enter passphrase for key '/c/Users/[user]/.ssh/id_rsa':
Linux li598-26.members.linode.com 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1 (2019-04-12) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have mail.
Last login: Tue Aug 20 18:37:55 2019 from 2600:1700:56a0:567f:64ef:ef32:9c86:4245

Now as root (or with sudo), we use the adduser command to create our new user.  You can just press enter at the prompts that appear:

root@li598-26:~# adduser grokman
Adding user `grokman' ...
Adding new group `grokman' (1000) ...
Adding new user `grokman' (1000) with group `grokman' ...
Creating home directory `/home/grokman' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for grokman
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]

Lastly, we can use the usermod command to add the user to the sudo group:

root@li598-26:~# usermod -aG sudo grokman

If you want to test it out – whoami should give you back root:

root@li598-26:~# su - grokman
grokman@li598-26:~$ sudo whoami

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for grokman:
root

 

Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *


Warning: Undefined array key "total_count_position" in /var/www/wordpress/wp-content/plugins/social-pug/inc/functions-frontend.php on line 46
shares