Saturday, October 16, 2010

Adding a Superuser Account to Linux

I have been testing a Linux Application and found it useful to create a second superuser account on the box besides the root account. Below are the list of commands that I used:

Check the current root account's user ID, group ID and group memberships:
    id root

Create account with superuser privileges (this is for CentOS 5.5):
    adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 LOGIN
    passwd LOGIN

Verify change:
    id LOGIN
    less /etc/passwd
    less /etc/shadow
    less /etc/group

To change the account properties:
    usermod [options] LOGIN

To delete the account if you don't care about the home directory:
    userdel -r LOGIN

If you chose not to delete the home directory and need to go back and do it later:
    rm -rf /home/LOGIN

A better way of doing this that aligns with best practice is to create a user and assign it to the wheel group and use 'sudo' instead:
    adduser -G 10 LOGIN
    Use 'visudo' to uncomment the below line:
# %wheel ALL=(ALL) ALL

No comments: