I was trying to edit the sudoers file using visudo in new Ubuntu system. The default editor was set to nano as usual.

After making the changes, when I went to save the file using Ctrl+O, I noticed that it was writing it out to /etc/sudoers.tmp file instead of /etc/sudoers file.

The explanation of why it was this way was interesting. I had never really put any thought to this earlier.

/etc/sodoers will always have 440 as the permissions. So even root does not have write access to it.

-r--r----- 1 root root 1830 Sep 16 07:24 /etc/sudoers

visudo does not simply open /etc/sudoers directly. It creates a temporary copy, invokes your editor on that temporary file, and then validates and installs the result.

I never knew about this before. Interesting!