A common administrative task is to give the user the possibility to run administrative commands as root. 1
By default only the user created at system installation time 2
can run commands as root by prefixing them with sudo. 3
There are 2 predefined group names: sudo on debian and ubuntu based distributions and wheel 4
on redhat and centos based distros. 5
If the user is part of this group then it can run 6
commands as root. I’m creating a new user called toor and then check 7
if it can run commands as root: so sudo useradd -m -s /bin/bash toor 8
The user was created. 9
Now I'll set its password. 10
And I'm becoming toor: su toor it's asking for his password 11
and I'm toor. 12
Let's see if it can run administrative commands: 13
so cat /etc/shadow only rooot can see this file. 14
Permission denied! Let's run the command with sudo! 15
I'm entering the correct password. 16
And it's not allowed. 17
I'm loogging out, but I want the newly created user to have administrative rights and I'm adding it 18
to the sudo group. 19
By the way, this is true for the new versions of Ubuntu; in older versions 20
the group name was admin. 21
So sudo usermod -aG sudo toor 22
I'm becoming toor 23
And I'll try to run the same administrative command as root: so sudo cat /etc/shadow, I'm entering 24
the password. 25
And it's working. 26
It was allowed to run the commad as root. That's because the user belongs to the sudo group. 27
Note that on CentOS, the group name is wheel. 28
Create the group, if it doesn't exist, add any user to the group and the user will be able to run administrative 29
commands aas root.