Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question
    
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
show 1 more comment

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

up vote 9 down vote accepted

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
uid=1000(warren) gid=1000(warren)groups=1000(warren),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)

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:

grub

Select recovery mode, then drop to root shell.

grub2

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.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# 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
%admin ALL=(ALL) ALL

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

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
share|improve this answer
add comment

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.

share|improve this answer
add comment

Go to the User Accounts.

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

Then, click on 'Advanced Settings'.

Advanced Settings
Image from How to create a Ubuntu 12.04 x64 LTSP server with 32bit thin clients by The Fan Club

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

Hope this helps!!

share|improve this answer
7  
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
add comment

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