LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Starting systemd service as non-root (https://www.linuxquestions.org/questions/linux-newbie-8/starting-systemd-service-as-non-root-4175637811/)

tankzeu 09-05-2018 02:45 AM

Starting systemd service as non-root
 
Hello,I was wondering can I configure .service file to be started,stopped,restarted without requiring root with the systemctl command?

pan64 09-05-2018 03:42 AM

as far as I know systemctl can only be executed by root. I don't know what do you want to achieve, but probably need to find another way to solve your issue.

ondoho 09-06-2018 01:42 AM

systemd itself will always need root privileges to start, but there's such a thing as user services:
https://wiki.archlinux.org/index.php/Systemd/User
iirc the initial setup still requires root, though.

X-LFS-2010 09-06-2018 06:20 PM

as far as I know, system checks for remote logins before light. this is said to be done to allow developers to easily do "remote debugging"

yes you can do it. it is simple as changing permissions. if you don't already know how it would be too difficult to fully describe in a reply post.

there are many articles about starting up OS services and how to make them run as a particular user with instructions what to do exactly

pan64 09-07-2018 02:32 AM

If you want to start a specific service as a user probably sudo can help you. But you still need to tell us what do you really need.

tankzeu 09-07-2018 02:53 AM

Quote:

Originally Posted by pan64 (Post 5900795)
If you want to start a specific service as a user probably sudo can help you. But you still need to tell us what do you really need.

So I am trying to distribute a service with systemd to many clients and when they start the service with "systemctl start someService.service" I don't want them to be required to type in the root password and also the start/stop/restart mechanism to be safe - by that I mean that if the service is started and the user logs out from the console and enter as another user the service should be stopped

pan64 09-07-2018 03:53 AM

Quote:

Originally Posted by tankzeu (Post 5900800)
I don't want them to be required to type in the root password

so check how sudo works.

Quote:

Originally Posted by tankzeu (Post 5900800)
if the service is started and the user logs out from the console and enter as another user the service should be stopped

This is a very different task and much harder to implement. If possible at all.
But probably someone can construct a helper script to implement it.


All times are GMT -5. The time now is 02:31 PM.