Sudo user in Debian

Install the “sudo” Command
You need to run this command as root user:

user@debian:~$ su -
Password:
root@debian:~ # apt-get install sudo

Create a new user account.

#/usr/sbin/adduser admin

Add the user to the sudo group; By default on Debian systems, members of the group sudo are granted with sudo access. To add a user to the sudo group use the usermod command:

#usermod -aG sudo admin

Check the sudo access

#id admin
uid=1001(admin) gid=1001(admin) groups=1001(admin),27(sudo)

The user admin a member of sudo group now and to work as a root, every command must start with sudo (sudo reboot, sudo vim, sudo del, sudo mkdir, sudo……)

Error and solutions

admin@debian9:~$ sudo ifconfig
sudo: unable to resolve host (none)

Solutions

Insert hostname to /etc/hostname and /etc/hosts something like:

127.0.0.1    localhost.localdomain localhost
127.0.1.1    debian9

Leave a Reply

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