Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Start/Stop Systemd Services as a non-root User?

SamBones

Programmer
Aug 8, 2002
3,186
0
36
US
I have some systemd services that I set up to run as a non-root user. I can do a 'status' on the services as that user, but I can't stop or start them without being prompted for the 'root' password. Is there any way to set this up?

In my .service definition files I do have the following...

Code:
[Service]
User=sensor
Group=sensor

...and the services are running as that user, but I can't start or stop them...

Code:
$ [b]systemctl stop sensor-08.service[/b]
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to stop 'sensor-08.service'.
Authenticating as: root
Password:

Any ideas?

Edit: Looking for a solution that doesn't use [tt]sudo[/tt].
 
Who owns the service? You might just need to chown to user "sensor" for it to work.
 
Why don't you want to use sudo? You can edit sudoers so that they can only run systemctl.

Other than that, if the service is owned by "sensor", you may be able to su -u sensor and stop the service that way.
 

Part and Inventory Search

Sponsor

Back
Top