When I edit /etc/sudoers using visudo, I think it saves to sudoers.tmp, checks it for errors, then copies it to the real /etc/sudoers.

However, I can't confirm my theory (how the lock file is used) in the man pages: http://manpages.ubuntu.com/manpages/dapper/man8/visudo.8.html - it's not described there.

Does anyone know if this behavior is described anywhere? Or is this because lock files are so common it's not described in visudo?

  • it is in the manpages: FILES ` /etc/sudoers ` List of who can run what /etc/sudoers.tmp Lock file for visudo Commented May 19, 2015 at 20:43
  • What I meant is: how the lock file is used, and what it does is not explained.
    – Tosh
    Commented May 19, 2015 at 20:52
  • 1
    Ah, I understand. I don't see a description. Your assumption is correct however: if you run sudo visudo look at the top line; it sais you are editing /etc/sudoers.tmp. Commented May 19, 2015 at 20:58

1 Answer 1


It is mentioned in man visudo.

From man visudo go to FILES section, you will find :

 /etc/sudoers.tmp          Lock file for visudo

It is also described in the illustration of -f option :

-f sudoers, --file=sudoers

Specify an alternate sudoers file location. With this option, visudo will edit (or check) the sudoers file of your choice, instead of the default, /etc/sudoers. The lock file used is the specified sudoers file with “.tmp” appended to it. In check-only mode only, the argument to -f may be ‘-’, indicating that sudoers will be read from the standard input.

If you are interested you can trace the system calls, here what you will find :

open("/etc/sudoers.tmp", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 7


Your concept is right and yes i also personally think that as this is a generic concept it is not mentioned in the man page.

  • Thanks, but would you mind taking a look at my clarification of the question below the question? Sorry for the confusion.
    – Tosh
    Commented May 19, 2015 at 20:54
  • @Tosh check my edits
    – heemayl
    Commented May 19, 2015 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .