visudo: sudoers file busy, try again later

Quick note on how to un-lock yourself from a failed visudo session.

If you’ve accidentally locked yourself out either via an accidental crtl-c or system restart and you were in the middle of editing /etc/sudoers via visudo there are two steps to take to restore it to a normal state (aka un-lock yourself)

I’ve done the following on an Ubuntu GNU/Linux system — but I’m assuming it is fairly cross-platform.

1) rm /etc/sudoers.tmp — this is the lockfile visudo creates

2) Double check permissions. If the /etc/sudoers file is not 440 (r–,r–,—) sudoers will barf. (Edit: Originally I had said to chmod u+x /etc/sudoers, but this was not correct, and could prevent you from sudoing)

  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit

  • m_gol
    NO! DON'T EVER TRY TO DO THAT ON UBUNTU!
    /etc/sudoers DO HAVE TO have permissions 440. And You propose to change it to 540. But then the system will not permit ANYBODY to use sudo command, due to incosistency. As in Ubuntu there is no root password by default, this makes anybody unable to gain root access!

    And the only way to repair it is to run a LiveCD system and repair the file...
  • saiza
    Damn,

    Please delete or give warning for line2

    I can't use sudo in my ubuntu because that command.
  • j_aix
    My SSH session had terminated while editing the sudoers file issue and rm /etc/sudoers.tmp DIDN'T work...here's what I had to do:

    ps -ef|grep sudo
    kill -9 visudo
    kill -9 vi /etc/sudoers.tmp
  • Michael
    i had to use
    pkill -9 visudo

    then i checked the integrity of the file with
    visudo -c
blog comments powered by Disqus