Sudo user in Debian

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

user@debian:~$ su -
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)


Insert hostname to /etc/hostname and /etc/hosts something like:    localhost.localdomain localhost    debian9

Add new User Group on CentOS 6 terminal

To add a New User and Assign a Group on CentOS 6 terminal

#useradd -g <groupname> username

For instance, lets say you wanted to add a new user named user to the apache group:

#useradd -G apache user

And then you’ll want to assign a password for that user, of course:

passwd user

Add or update User to an an Group

#usermod -a -G <groupname> username

Change a User Primary Group

Sometimes a user has many group, this is switch out the primary group that a user is assigned to with this command:

#usermod -g <groupname> username

View a User Group Assignments by use the id command to see what groups the user is assigned to:

id <username>

This will display output something like this:

uid=500(howtogeek) gid=500(howtogeek) groups=500(howtogeek), 1093(admins)