Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 27824  / 1 Year ago, thu, april 13, 2023, 10:20:01

I get the following error while trying to update my repositories,



avinash@avinash-VirtualBox:~$ sudo apt-get update
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin


It seems like I had accidentally deleted my /etc/sudoers file./etc/sudoers file was actually belongs to sudo package, so i try to reinstall sudo by pkexec but it won't work.



avinash@avinash-VirtualBox:~$ pkexec apt-get install sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
sudo is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 301 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up sudo (1.8.6p3-0ubuntu3.1) ...
WARNING: /etc/sudoers not present!
chown: cannot access ‘/etc/sudoers’: No such file or directory
dpkg: error processing sudo (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
sudo
E: Sub-process /usr/bin/dpkg returned an error code (1)
avinash@avinash-VirtualBox:~$


And also I had tried,



avinash@avinash-VirtualBox:~$ pkexec apt-get install --reinstall sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 301 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for sudo:amd64


How can i make sudo command to work again?


More From » sudo

 Answers
6

Just boot from Ubuntu live disk and copy /etc/sudoers file to the installed Ubuntu partition's /etc directory.




  • Boot Ubuntu live dis and click try Ubuntu option on startup.


  • Run sudo blkid command to know the installed Ubuntu's partition id.


  • Mount the installed Ubuntu's partition on a specific directory like below,



    sudo mkdir /media/foo
    sudo mount /dev/sdaX /media/foo # /dev/sdaX installed Ubuntu's partition id.

  • Now copy the live disk's sudoers file to the /etc directory of installed Ubuntu's partition.



    sudo cp /etc/sudoers /media/foo/etc

  • Now boot from the hard-disk(Boot your Ubuntu OS).It will work.



[#26383] Thursday, April 13, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pardsea

Total Points: 290
Total Questions: 115
Total Answers: 98

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
;