TransWikia.com

How to run "systemctl" + $ + "apache" $=stop,start,restart as non sudo/root user?

Ask Ubuntu Asked by Just a dude on December 13, 2021

Yeah basically the title,
I want to do that things from a app that can run Linux scripts per SSH.
I only want to run these three and not ALL from systemctl with my basic user.

So thanks.

2 Answers

Try to use the --user switch. From systemctl(1)

--user

Talk to the service manager of the calling user, rather than the 

service manager of the system.

You may follow the instruction of this post.

Answered by abu_bua on December 13, 2021

Create a Cmnd_Alias in /etc/sudoers like:

Cmnd_Alias APACHEADMIN = /usr/bin/systemctl start apache2, /usr/bin/systemctl restart apache2, /usr/bin/systemctl stop apache2

Then add a line for the user privilege:

jsmith  ALL = NOPASSWD: APACHEADMIN

Answered by Felicia on December 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP