Allow User Account to run a single command using SUDO privelages

I have a machine running Ubuntu 12.10. I have two user accounts setup, my account, and another user. I am able to run SUDO commands, but the other user isn’t in the SUDO’ers list.

What I’m trying to do is give mininal permissions for the other user to run a single SUDO command. Basically to eject an Amazon Kindle USB device.

sudo eject /dev/sdc1

When plugging the Kindle in to the USB port, the device is mounted. If the user simply Ejects the device using the UI, the device is unmounted but not ejected – so the device can pull charge from the PC.

Ejecting the Kindle using the command above works on my account, allowing me to charge the Kindle. But when the other user is logged in, he can’t run the command.

Is there a way to allow a user account to run a single command with SUDO permissions?

Answer

Use sudoedit to edit the file /etc/sudoers

Underneath the line root ALL=(ALL:ALL) ALL

Enter the line below and replace ejectuser with the actual username
ejectuser ALL=(root)NOPASSWD:/usr/bin/eject

Attribution
Source : Link , Question Author : spelk , Answer Author : GeNeSiX

Leave a Comment