Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed Ubuntu 12.10 on my 32-bit machine using Ubuntu installer and gave a password(and the account name was 'samsung') when prompted. Later I was able to use that password for logging in, locking-unlocking, authentication etc.(I guess that's because I was the administrator then). But now,I have changed the account type from "administrator" to "standard" by mistake and whenever it needs to authenticate during any process(like connecting to a wi-fi,unlocking my user account), it asks me to give the password for root, but unfortunately the same password is not working. Tasks other than authentication(like loging in etc.) is working fine. I have changed the password several times but with no solution. If I use 'sudo' in terminal,it says "samsung is not in the sudoers file. This incident will be reported." How can I regain control?

share|improve this question
up vote 0 down vote accepted

Ubuntu, by default, has no password for the user root.

If you locked yourself out of your system,

  1. select "recovery mode" in the grub boot menu, when starting your machine. If you don't see a boot menu, you may need to press Shift during a time window of a few seconds after BIOS stage.

    This gives you root access and the power to grant your regular user account its administrative privileges.

  2. Enable write access on /¹.

    mount -o remount,rw /
    
  3. Add admin to the groups of your account.

    usermod -a -G admin [account name]
    
  4. Reboot and everything should be back to normal.

¹ I'm not sure whether the recovery mode of Ubuntu 12.10 mounts the root file system or just the initramfs.

share|improve this answer
    
I have tried this. If I write 'admin', it says 'admin' group not found(I have also tried some other variations like Admin,Administrator etc with same result). When I write 'root' instead. It says something like "cannot lock /dev/passwd; try again later." :( – Snehasish Karmakar Oct 14 '13 at 9:33
    
From what I remember the recovery mode mounts the root file system read-only. You need to remount it with write access as described in the edited answer. – David Foerster Oct 14 '13 at 14:40
    
You are right. But, Ubuntu 12.10 has no group named "admin", instead, "sudo" works. Perhaps, "adm" also works.Now, can you tell me how I can change user name "samsung" to my name? :) I have changed the name by going into "User Accounts" via "System Settings",but it seems to have no effect! "samsung" is still there as group(!) as well as user. – Snehasish Karmakar Oct 15 '13 at 19:03
    
This is an entirely different question. Go on and open one! :-] – David Foerster Oct 15 '13 at 19:05

I think the best way would be editting the sudoers file. To to this you must boot your system from a Ubuntu-USB-Stick or CD or any other bootable Live Linux (maybe the Ubuntu Recovery Mode also works, didn't used it yet), mount the partition where you installed Ubuntu and then edit the file /etc/sudoers. If you put in something like samsung ALL=NOPASSWD: ALL you can get root after reboot without any password. There are still a lot of other possibilities but i think this would be the easiest.

share|improve this answer

If you really set root password (Ubuntu don't ask for it by default, AFAIR), you can add init=/bin/sh to your linux command line during boot (check grub2 documentation how to do it) and then run passwd to change root password or add your user samsung to group sudo or another that used in Ubuntu for granting sudo

If password is not set you can just boot to recovery mode - it will show you root shell after boot and from that shell you can do whatever you want (add your user to group or change root password)

share|improve this answer

In addition to David Foerster's instructions, if the menu doesn't appear for recovery mode, you can tell grub to boot into single user mode like this.

(Paraphrasing:) Highlight your grub boot entry, hit "e" to edit, and at the end of the line starting with "linux", add the word "single" and boot. This will get you to an administrator command prompt.

share|improve this answer

Boot in single user mode. Then it is logged in as root directly. Follow the below to log in to the system in single usermode. No network will be available in this mode. To boot into single user mode you edit the boot instructions for the GRUB menu entry you wish to boot and add the kernel parameter/option single. Brief instructions for how to do this are below.

Select (highlight) the GRUB boot menu entry you wish to use. Press e to edit the GRUB boot commands for the selected boot menu entry. Look near the bottom of the list of commands for lines similar to

linux /boot/vmlinuz-3.2.0-24-generic root=UUID=bc6f8146-1523-46a6-8b\ 
6a-64b819ccf2b7 ro quiet splash 
initrd /boot/initrd.img-3.2.0-24-generic

Change the middle line in (3) by adding the kernel boot parameter single to the end of the line (i.e. after ro quiet splash).

For this example you would change 
6a-64b819ccf2b7 ro quiet splash 
to 
6a-64b819ccf2b7 ro quiet splash single

Press either Ctrl+X or F10 to boot using these kernel options.

Note: These changes are not persistent. Any change to the kernel boot options made this way will only affect the next boot and only if you start that boot by pressing either Ctrl+X or F10 while still in GRUB edit mode.

You will be then logged in as root in a terminal window as root. You can change the password by the command.

 [root@localhost ~]# passwd root
Changing password for user root.
New password: 
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .