2009-05-06

A tricky point of /etc/sudoers

There is a definition in /etc/sudoers, "Cmnd_Alias". I failed on a tricky format, and spend 3 hours to figure it out.

Cmnd_Alias TEST = vi /etc/passwd,

Simple, looks like nothing wrong. But this is a syntax error. "visudo" won't allow you to save it.

The correct format should be,

Cmnd_Alias TEST = /usr/bin/vi /etc/passwd

The key point here is /etc/sudoers requires a FULL PATH for any command and file name. It is not only applied to Cmnd_Alias definition, it applies to all commands show-up in /etc/sudoers.

P.S., remember to use "visudo" to edit /etc/sudoers, it helps a lot.