I cant use sudo on my azure vm with redhat 7

Carron Muleya 21 Reputation points
2023-01-04T11:52:05.697+00:00

Please help me, my sudoer file is incorrect, after adding a new line wich was wrong. Now I cant use sudo, when am trying to fix this, I will be asked for root password that I don't even know. See below

  • sudo pkexec vim

/etc/sudoers: syntax error near line 121 <<< sudo: parse error in /etc/sudoers near line 121 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin*

when trying without sudo

pkexec vim ==== AUTHENTICATING FOR org.freedesktop.policykit.exec === Authentication is needed to run `/usr/bin/vim' as the super user Authenticating as: root Password: polkit-agent-helper-1: pam_authenticate failed: Authentication failure

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,041 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 38,021 Reputation points Microsoft Employee Moderator
    2023-01-04T18:40:34.483+00:00

    @Carron Muleya
    Since you have broken your sudoers file you will not be able to fix it on the running VM. Please create a snapshot of your OS disk. Then create a disk from snapshot and attach it to a recovery VM. On the recovery VM you can mount the root directory of the broken OS. You will be able to get root on the recovery VM and edit the sudoers file. Once fixed you can swap the OS disk of your VM to this one that has been repaired.

    Hope this helps. Please let me know if you are still having issues and we will be happy to assist.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.