Ubuntu’fying RedHat/CentOS – Enabling “sudo”

For better or worse, my main personal PC and netbook are now running Ubuntu Linux. I still maintain a CentOS image running under VMWare on my main PC, so that I can do compilation and other development work in an environment that matches what the customer has.

One niggling thing is that on Ubuntu, there is no real “root” password. Instead, it works on the principle that certain users are granted an administrative access level, and can execute administrative commands via the sudo interface. When invoking sudo, they user needs to specify specify his or her own password, to prove that they are who they are.

On RedHat/CentOS, by default, administrative commands are executed by temporarily changing your ID to that of the root user, via the “su – root” command. To do this succesfully, you have to provide the root password for the system.

The difference can be quite irritating when you switch frequently between the two boxes. So here’s a tip on how to get RedHat/CentOS to behave the Ubuntu way:

As root, edit the file /etc/sudoers, and remove the leading “#” from the line:

%wheel ALL=(ALL) ALL

Now, think about it a few times, and then grant the user administrative access:

usermod –append –groups wheel shahada

And that’s it, you can now use sudo in RedHat/CentOS just like in Ubuntu:

[shahada@buildbox ~]$ sudo id
Password: (shahada’s passsword)
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

And if you’re wondering where the term wheel comes from, read this: http://en.wikipedia.org/wiki/Wheel_(Unix_term)

This post was originally published as a Facebook Note at 2010-01-14 02:32:54 +0800.

You may also like...