LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   RHEL/CentOS 7: Problem with systemctl --root= option (https://www.linuxquestions.org/questions/centos-111/rhel-centos-7-problem-with-systemctl-root%3D-option-4175646383/)

imperialguy 01-17-2019 06:30 AM

RHEL/CentOS 7: Problem with systemctl --root= option
 
It is my understanding that --root= option in systemctl command is used to explicitly specify an alternate root path to find the service unit files.

On RHEL/CentOS 7, the following error occurs when attempting to use the above mentioned systemctl option:

Code:

[root@server-02 system]# systemctl --root=/myservices/mds start xyz.service
Failed to get D-Bus connection: Operation not permitted

Please note that the above command is run as root.

So, the idea behind the above command is that I am telling systemctl to find the service called xyz.service in the path /myservices/mds, as opposed to the default search paths like /etc/systemd/system or /run/systemd/system

Any idea why this is not working? If --root is not going to work, is there any other way to specify a custom search path?

Would really appreciate the help.

syg00 01-17-2019 06:41 AM

The message tells why it is not working. Try sudo.

imperialguy 01-17-2019 07:00 AM

@syg00 I am running the command as root

berndbausch 01-17-2019 07:07 AM

Quote:

Originally Posted by imperialguy (Post 5950143)
@syg00 I am running the command as root

Then remove the sudo. It might remove some environment variables that are required for this to work (just guessing).

EDIT: From the man page:
Code:

--root=

    When used with enable/disable/is-enabled (and related commands),
    use the specified root path when looking for unit files.
    If this option is present, systemctl will operate on the file system
    directly, instead of communicating with the systemd daemon to carry out
    changes.

It says nothing about starting a service.

imperialguy 01-17-2019 07:08 AM

@berndbausch Still doesn't work

imperialguy 01-17-2019 07:13 AM

Now I am getting this:

Code:

[root@server-02 ~]# systemctl --root=/myservices/mds enable xyz.service
Operation failed: No such file or directory



All times are GMT -5. The time now is 05:53 AM.