6

There is an issue when I try to run the command sudo visudo and the error was shown:

visudo: /etc/sudoers busy ,try again later
10
  • Try restarting the computer.
    – user689314
    Jul 6 '17 at 6:47
  • still it's not working. Jul 6 '17 at 6:52
  • 2
    What is the output of sudo lsof /etc/sudoers ?
    – Ravexina
    Jul 6 '17 at 6:52
  • lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output information may be incomplete. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME visudo 9348 root 5uW REG 8,1 755 9699545 /etc/sudoers Jul 6 '17 at 6:55
  • So you have other process editing the sudoers file. Jul 6 '17 at 6:56
8

First find out which process is using /etc/sudoers file:

sudo lsof /etc/sudoers

from your outputs, seems it's another visudo instance:

visudo 9348 root 5uW REG 8,1 755 9699545 /etc/sudoers 

so, start a root shell:

sudo -i

then run:

kill -15 9348
ps --no-heading 9348 || kill -9 9348

open another terminal, run:

sudo visudo

make sure everything works fine, then you can log out from your root shell.

0
0

If you still have this problem and can't kill the process then you can use some other editors like nano.

nano /etc/sudoers
3
  • that might work, but it's not a good idea to edit /etc/sudoers with another text editor as if one breaks it with incorrect syntax (which visudo prevents) sudo will not work and one will not be able to fix it
    – Zanna
    Aug 9 '21 at 9:24
  • I agree with you, but sometimes we need that if we have incorrect syntax in sudoers and want to fix it so visudo works again. Aug 10 '21 at 9:17
  • 1
    I am disinclined to test, but I don't think sudo works at all in such cases (man 5 sudoers says "The sudoers file should always be edited by the visudo command which locks the file and does grammatical checking. It is im‐ perative that the sudoers file be free of syntax errors since sudo will not run with a syntactically incorrect sudoers file."), and certainly one cannot edit /etc/sudoers without being root, so unless one has a way of becoming root without sudo, which is not usually the case on Ubuntu, one is in a pickle.
    – Zanna
    Aug 10 '21 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.