0

I moved the file /etc/sudoers to /etc/sudoers.bkp after this I cannot run sudo command and neither can login as root and change the file back is there any way this can be resolved without reinstalling the system

Operating System: Red Hat Enterprise Linux 8.4 (Ootpa)

Please suggest

  • Stop the system, boot on USB key, mount your official system and move the file to the right place. The reboot without key – Dom Aug 24 '21 at 08:47

2 Answers2

1

You can start the emergency mode and then change the name of the file

Bootup into Emergency mode(target)

  1. During bootup, when the GRUB2 menu shows up, press the e key for edit.

  2. Add the following parameter at the end of the linux16 line :

systemd.unit=emergency.target

  1. Press Ctrl+x to boot the system with the parameter.

OR

  1. Method 1 There is a GRUB2 menu option when you boot up the system which can be selected to directly boot into rescue mode.

  2. Method 2

  3. During bootup, when the GRUB2 menu shows up, press the e key for edit.

  4. Add the following parameter at the end of the linux16 line:

systemd.unit=rescue.target

  1. Press Ctrl+x to boot the system with the parameter

Try this and rename the file, if you want to backup never use the command mv, now your learn in a tough way is better use the command cp. The mv command rename a file when we use the same dir and move the file into a new location if you specify this new location

Good luck pal

Alejandro F.
  • 497
  • 3
  • 8
  • This is done in a Ec2 instance so I am not sure if boot time steps can be done. – Sarthak Saxena Aug 25 '21 at 09:10
  • Here are [the instructions to do this on an EC2 instance](https://aws.amazon.com/de/blogs/compute/using-ec2-serial-console-to-access-the-grub-menu-and-recover-from-boot-failures/) - good luck! – digijay Aug 25 '21 at 21:21
0

The issue caused by mistake
instead of

#includedir /etc/sudoers.d

the last line was modified into

#includedir /etc/sudoers
Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89