0

When I run this command

sudo systemctl enable /home/ec2-user/my_custom.service

I get

Failed to enable unit: Access denied

And When I run

systemctl enable /home/ec2-user/my_custom.service

I get

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ====
Authentication is required to manage system service or unit files.
Authenticating as: Cloud User (ec2-user)
Password: 
==== AUTHENTICATION COMPLETE ====
Failed to enable unit: Access denied

Now here I don't have any password to setting the new using sudo passwd ec2-user and then using that password but still the same error

Here is content of my_custom.service

[Unit]
Description=go_responder
After=network.target

[Service]
Type=simple
User=ec2-user
ExecStart=/home/ec2-user/custom_service_executable

[Install]
WantedBy=default.target
0

Systemd units must be placed in one of the search paths that systemd looks for unit files in. They cannot be placed in any other directory.

Copy the file to /etc/systemd/system, run sudo systemctl daemon-reload and then you will be able to enable your service.

  • The same thing works normally and perfectly from /home/user/custom.service in Ubuntu 18 and Centos 7 also. Is this different in RHFL? – kanudo Jun 9 at 15:02
  • I followed the steps that you said but again the same error on RHEL – kanudo Jun 10 at 4:26
  • Hm. Does your executable exist? Is it actually executable? – Michael Hampton Jun 10 at 4:30
  • Yes its an executable. I can run it using the ./executable command. Every time i just get Failed to enable unit: Access denied – kanudo Jun 10 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.