i've got a regular user i want to turn into admin group so he can have same privileges as a root.

should i just change the GID in /etc/passwd and /etc/group or should i use usermod/groupmod?


You do not want to make this user EXACTLY the same as root. Don't change uid and gid. You have a few options:

  • Use sudo. sudo lets a user execute a command or start a shell as root, without needing the root password. However, the admin of the computer can tightly control which commands a user can "sudo". Read up the man page. But if you want an easy "let this user run any thing with sudo", put this user in the /etc/sudoers file. Even better, put this user in the admin group then add the line %admin ALL=(ALL) ALL to /etc/sudoers. On Ubuntu, this is probably your best option as sudo is installed by default.

  • Put this user in the wheel or admin group. This user won't be root, but will have the same access to files as everyone else in wheel or admin.

  • Give the user the root password and make this user use su <cmd>. This is a bad idea. On recent versions of Ubuntu, the root account can't login by default so you can't do this.

| improve this answer | |
  • 3
    Ubuntu does not have a root account enabled unless an adminstrator takes steps to enable it – DaveParillo Apr 9 '10 at 3:45
  • Thanks, I didn't spot that in the tags, but edited the answer to include it. – kbyrd Apr 9 '10 at 15:20

Your best bet under ubuntu is to add the person to the sudoers file. You should use visudo to edit this file. If you hate vi, you can set the EDITOR shell variable to use your preferred editor.

You have many choices when adding a peson as a sudoer. You don't have to give them blanket root access if you don't want to. In general the lines in /etc/sudoers looks like:

 usernames/group servername = (usernames command can be run as) command

There are some general guidelines when editing this file:

  • Groups are the same as user groups and are differentiated from regular users by a % at the beginning. The Linux user group "users" would be represented by %users.
  • You can have multiple usernames per line separated by commas.
  • Multiple commands also can be separated by commas. Spaces are considered part of the command.
  • The keyword ALL can mean all usernames, groups, commands and servers.
  • If you run out of space on a line, you can end it with a back slash () and continue on the next line.
  • sudo assumes that the sudoers file will be used network wide, and therefore offers the option to specify the names of servers which will be using it in the servername position in Table 9-1. In most cases, the file is used by only one server and the keyword ALL suffices for the server name.
  • The NOPASSWD keyword provides access without prompting for your password.

You can use /etc/sudoers to grant specific access to specifc people for any or all applications.

This site includes some decent examples.

| improve this answer | |

In a default Ubuntu installation, you can simply add the user to the "admin" group: adduser USERNAME admin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.