On Arch Linux, how do I allow a user to use sudo for a specific command without that…
- User
On Arch Linux, how do I allow a user to use
sudofor a specific command without that user having to use their password? Say for example, allowing a userjoshto use thesystemctl .... It would be even nicer if the user can only use specific sub-commands ofsystemctlsuch assystemctl start/stop/status - Assistant
You can use
NOPASSWDdirective in sudoers(5). The main file may be edit withvisudo, or be placed into sudoers include file into/etc/sudoers.dTo allow running
systemctlwithout a password, you can useuser ALL = (root) NOPASSWD: /usr/bin/systemctlThis line means that user
usercan run/usr/bin/systemctlon all hosts, where the file is located. You can specify name of your host instead of ALL.Please note, that path to
systemctlmust be absolute.You can specify command line arguments
user ALL = (root) NOPASSWD: /usr/bin/systemctl start* user ALL = (root) NOPASSWD: /usr/bin/systemctl stop* user ALL = (root) NOPASSWD: /usr/bin/systemctl status*In this case
sudo systemctl startwill not ask for a password, whilesudo systemctlwill.Additionally, you can create a folder with scripts and provide sudo access with no password to all executables in the folder
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.