# How to recover root user [duplicate]

I have accidentally changed the root user from administrator type to basic type in the user account page, and now i have no whatever root previligaes on the system, how i can switch back to administrator type?

-

## marked as duplicate by Eliah Kagan, Eric Carvalho, Nathan Osman, Thomas W., Basharat SialviApr 9 '13 at 1:01

is it even possible? –  green7 Apr 8 '13 at 18:02
@green7 Yes, he didn't actually change the root user, he just changed the only normal account with admin privileges (so able to use sudo) to one without admin privileges (unable to use sudo). –  handuel Apr 8 '13 at 18:03
@green7 Although I do admit, the gui shouldn't really let you do that. Fair enough allowing removal from sudo using the command line, but the gui shouldn't allow a user to accidentally lock themselves out of making system changes. –  handuel Apr 8 '13 at 18:15
@green7 worst case you can fix these sorts of problems by booting an alternate OS and using a recovery/penetration tool to overwrite the existing accounts/permissions with new ones. –  Dan Neely Apr 8 '13 at 19:04
@DanNeely I was thinking on similar lines. Probably just adding the username to /etc/group using a live CD would work? –  green7 Apr 8 '13 at 19:05

Assuming you have not actually changed the root user but removed the first user from the list of administers then this is relatively easy to fix.

Press CTRL+ALT+T and enter id

You should see something similar to.

~\$ id


If this shows sudo you should be an administrator. In Ubuntu prior to 12.04 the group was admin If not this is the problem.

First you need to boot to a root shell if you don't normally see grub when you boot hold SHIFT.

You should see something like this:

Select recovery mode, then drop to root shell.

Finally mount the file system read write

mount -o rw,remount /


If the problem was that you were not in the sudo group it can be fixed with

usermod -aG sudo warren


replacing warren with your user name. If you are not sure what the user name should be it was the uid= field from the id command you ran earlier.

replace sudo with admin if you are using a version of Ubuntu prior to 12.04.

Another less likely possibility is that you have changed the sudoers file

If this is the problem then enter

visudo


Edit this file to look like this (12.04 default):

#
# This file MUST be edited with the 'visudo' command as root.
#
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

#includedir /etc/sudoers.d

-

At the grub boot selection screen (if this doesn't show up hold shift at boot) select ubuntu recovery mode and press enter, then select root terminal (or something similar it may be called root shell) from the list of options. Then type mount -o rw,remount / to gain read/write access to the filesystem. Then type adduser adminusernamehere sudo to give the admin user that you changed to standard sudo (root) privileges.

-

Go to the User Accounts.

Image from Eliah Kagan's answer to How to manage users and groups?

Then, tick any boxes you want. The one you want though, is Administer the System.

Hope this helps!!

-
He can't do that as he can't change settings in user accounts, due to not having an administrator account on the system. –  handuel Apr 8 '13 at 18:10