2

I've accidentally removed myself from sudoers file by doing usermod -G user group without -a, and now I am not in the sudoers group. I've tried doing su - and entering root's password but it says su: Authecation failure. Is there a way to add myself back? Using Fedora 20.

JadedTuna
  • 123

3 Answers3

1

If you don't have root password, You have to boot with a Live-CD and chroot to your partition, find out to read only mounted or rw mounted with mount command.
If read only mounted, use the following command:

mount -o rw,remount /

Then use :

passwd root
PersianGulf
  • 10,850
1

You can do this in single user mode.

  1. Restart system, at grub prompt press down or up arrow so grub screen will be pause.
  2. Press "e" to edit grub entries,
  3. Select the kernel line and again press "e" to edit mode
  4. Now add "1" or "single" at end of the line. and press enter.
  5. Press "b" to boot with this setting. Now fedora will start in single user mode.
  6. Now you can reset root password with below command
passwd
  1. As well as you can edit file /etc/sudouser to assign sudo privileges to other users.

UPDATE ---

For GRUB2

  1. Use the arrow keys to select the boot entry you want to edit
  2. Press e to start editing that entry
  3. Use the arrow keys to go to the line that starts with linux or linux16
  4. If you have a UEFI system it's the line that starts with linuxefi
  5. Go the the end of that line add a space then rw then another space and init=/bin/bash Press Ctrl-x or F10 to boot that entry
  6. Now you can reset root password with below command
passwd
  • I've tried doing that, but it says Welcome to the rescue mode! Type "systemctl default" or ^D to enter default mode.. It seems like it is asking me for root password. Any ideas what do I do? – JadedTuna Nov 19 '14 at 18:28
  • @Vik2015 please check this below link to use rescue mode with Fedora CD and edit the suduser's file .. http://docs.fedoraproject.org/en-US/Fedora/20/html/Installation_Guide/sect-boot-options-rescue.html – Vaibhav Panmand Nov 19 '14 at 18:38
  • Also check this for single user mode..... http://docs.fedoraproject.org/en-US/Fedora/11/html/Installation_Guide/s1-rescuemode-booting-single.html – Vaibhav Panmand Nov 19 '14 at 18:41
  • @VaihavPanmand, I've managed to fix it. Your answer was almost right, but it is not for GRUB2 (and it looks like I have GRUB2 installed). Please add steps for GRUB2 (available here: http://fedoraproject.org/wiki/How_to_reset_a_root_password) and I can accept your answer. – JadedTuna Nov 19 '14 at 18:44
  • @Vik2015 I've updated grub2 in my answer :) – Vaibhav Panmand Nov 19 '14 at 18:48
1

try sudo cat /etc/sudoers and based on what is there and the restrictions on the user you may have some luck with "sudo sed", "sudo grep", or even "sudo vi" to edit the /etc/sudoers directly or indirectly. This worked for me when I playing with sudo.

jouell
  • 115