5.9. Prohibiting Command Arguments with sudo


You want to permit a command to be run via sudo, but only without command-line arguments.


Follow the program name with the single argument “” in /etc/sudoers:

smith  ALL = (root) /usr/local/bin/mycommand ""

smith$ sudo -u root mycommand a b c                         Rejected
smith$ sudo -u root mycommand                               Authorized


If you specify no arguments to a command in /etc/sudoers, then by default any arguments are permitted.

smith  ALL = (root) /usr/local/bin/mycommand

smith$ sudo -u root mycommand a b c                         Authorized

Use “” to prevent any runtime arguments from being authorized.

See Also

sudo(8), sudoers(5).

Get Linux Security Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.