Adding user to SUDOERS in CentOS 6, 6.4, 6.5, RHEL6, RHEL 6.3, 6.4

Here we can see how to add the sudo in Centos, In Ubuntu by Default sudo will be enabled, But in Centos and RHEL there is not sudo enabled by deafult, we can see here how to access the root privilage from other user by adding the user to Sudo Group.

Switch to Root user using su

$ su

Edit the Sudoer’s file using vim

# vim /etc/sudoers

 

Go to Line 98, Look for Below command

## Allow root to run any commands anywhere
root     ALL=(ALL)     ALL

 

add this line, replacing [USERNAME] with your Respective username)

Syntax:

[USERNAME]     ALL=(ALL)     ALL

 

Here i have added a user named linuxmental to sudoer below

## Allow root to run any commands anywhere
root     ALL=(ALL)     ALL
linuxmental	ALL=(ALL)     ALL

Save the file and Exit using wq!

Then switch to normal user linuxmental and execute some commands with sudoers privilage.

Output:

[linuxmental@centos ~]$ sudo /etc/init.d/network restart
Shutting down interface eth0:[  OK  ]Shutting down loopback interface:[  OK  ]Bringing up loopback interface:[  OK  ]Bringing up interface eth0:[  OK  ]

 

That’s it …

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s