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.
Asked
Active
Viewed 2,553 times
2

JadedTuna
- 123
-
You have to ask your administaror. – PersianGulf Nov 19 '14 at 17:14
-
@MohsenPahlevanzadeh, I am the administrator (if you mean computer owner). – JadedTuna Nov 19 '14 at 17:18
-
2I think you've actually forgotten root's password.Try logging in as root from a console. If that fails: http://unix.stackexchange.com/questions/168417/break-the-root-password/168422#168422 – goldilocks Nov 19 '14 at 17:20
3 Answers
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.
- Restart system, at grub prompt press down or up arrow so grub screen will be pause.
- Press "e" to edit grub entries,
- Select the kernel line and again press "e" to edit mode
- Now add "1" or "single" at end of the line. and press enter.
- Press "b" to boot with this setting. Now fedora will start in single user mode.
- Now you can reset root password with below command
passwd
- As well as you can edit file /etc/sudouser to assign sudo privileges to other users.
UPDATE ---
For GRUB2
- Use the arrow keys to select the boot entry you want to edit
- Press e to start editing that entry
- Use the arrow keys to go to the line that starts with linux or linux16
- If you have a UEFI system it's the line that starts with linuxefi
- 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
- Now you can reset root password with below command
passwd

Vaibhav Panmand
- 601
-
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
-
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