Centos 6/RHEL create administrative user using root with su

You can create an administrative user and provide them with access to the su or switch user command that enables them to change the ownership of a login session in order to become root or any other user.

Managing a server as the root user is probably not the best way to work as you are leaving yourself open to a whole host of issues that can give rise to a multitude of errors. 

Using of the root user account should be left until it is required, so here we configure a day-to-day administrative user who can switch to using root with the su command.

To start with, log in as root and create your new user, in this case anton

# useradd anton

# passwd anton

Use alphanumeric between 6 - 16 characters long.

Now add the user to the wheel group

# usermod -a -G wheel anton

Now we activate the wheel module in PAM

The PAM or the Pluggable Authentication Module provides a global method of authenticating users across the system as a whole without any individual program being required to know which authentication system will be use.

# vi /etc/pam.d/su

Vi an Vim commands

Scroll down and uncomment the following line

auth required pam_wheel.so use_uid

Save and exit the file.

Now you have activated the su command for the user and it can become root user by issuing the su command

$ su anton 

To end the session use the exit command

$ exit

And the whoami command to determine which user is active 

With the Centos live cd I am currently using to type this

$ whoami
centoslive




See also adding a user to a Centos 6 Fluxbox Desktop







 


Labels: , ,