Monday, January 14, 2008

Linux sudo tip : Creating a new super user with admin rights in Linux




Before all you linux fanatics start shooting at me for misusing sudo in this article, let me make a confession here. More than once I have felt the need for multiple accounts with root like privileges and it is really painful to understand and modify sudo for this simple purpose. It is not a unique issue, especially new users who have just migrated from the world of Windows. We are so used to administrative and debugger privileges.

Here I'll show you a quick way to create a new superuser who has almost all rights as the root and you don't really need to understand how sudo works.



1. Let us start. Let us create a new user called root2 first
useradd root2
passwd root2


2. Next stept. If you guessed that it has something to do with modifying sudoers file, you are right.
Modify /etc/sudoers using the visudo which is a sudoers file editor and syntax checker.

sudo visudo


2.Go down to the line # User privilege specification‘ You should see root ALL=(ALL) ALL

and add this line after that
root2 ALL=(ALL) ALL



3. Next, you need to add around 50 lines of code. Nah, just kidding. You are done.
Restart and test your power. Now you can sudo and run anything without the need for the root password or any explicit permission.

4. Please do note, with great powers comes great responsibilities. There is a reason why Linux has the concept of root. If you have more time, I would suggest reading the following article to get more finer control on restricting access of specific commands to users and groups.

For more details on sudo: Do look at this article

Post a Comment