Skip to main content

CREATING SUDO USERS/GROUPS IN CENTOS/UBUNTU

1.By adding user to group having sudo privilege

UBUNTU
First create a user to which we want to have sudo privileges.Here arun is the user to which we are assigning sudo privilege.
#useradd arun
Set a password for user arun
#passwd arun
Set the password
Add this user to sudo group. By default, on Ubuntu, members of the sudo group have sudo privileges.
#usermod -aG sudo arun
Now switch to user arun.
#su arun
Now we can start using sudo privileges.For example
$sudo ls -al

Note:For ubuntu under ubuntu 11.0 we can use sudo group as admin

CENTOS
First create a user to which we want to have sudo privileges
#useradd arun
Set a password for user arun
#passwd arun
Set the password
Add this user to sudo group. By default, on Ubuntu, members of the sudo group have sudo privileges.
#usermod -aG wheel arun
Now switch to user arun.
#su arun
Now we can start using sudo privileges.For example
$sudo ls -al


2.By visudo
#useradd popy
#passwd popy
Set a password for user popy
Here we are creating a new user popy to which we assign sudo privilege
#visudo
This command will opens a file where we can edit users and groups which we want to give sudo privilege



Here iam entering user popy
Popy   ALL=(ALL)   ALL
Similarly we can also add group we want.