sudo: unable to stat /etc/sudoers: No such file or directory

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


Solution 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