How to allow a user to run a single command as root via sudo

In order to allow a user to run a single command as root using sudo run the following as root:

echo "user ALL= NOPASSWD : /bin/file" >> /etc/sudoers

Where user is the specified username and /bin/file if the path to the binary that we are allowing this user to run.

If you want to do further changes to the sudoers file it’s recommended to use the command ‘visudo’ to do so.

Español

Para poder hacer esta tarea solo tenemos que ejecutar el siguiente comando como root:

echo "user ALL= NOPASSWD : /bin/file" >> /etc/sudoers

Donde user es el usuario al que le queremos dar permisos y /bin/file es la dirección o path es el archivo binario que le vamos a permitir ejecutar.

Para hacer más cambios al archivo sudoers es recomendable utilizar el comando ‘visudo’.

One thought on “How to allow a user to run a single command as root via sudo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s