Can't run nexus as nexus user

As per the setup documentation I created a nexus user without sudo privileges. I edited the nexus.rc file and instruct it to to use the nexus user. The two folders under /opt are both owned by the nexus user. running “/etc/init.d/nexus start” fails and produces no logs as to why it failed. I am at a loss. Any advice would be greatly appreciated.

If your Linux system uses systemd then you should use that to launch. That will not require sudo.

If your Linux system does not use systemd then the /etc/init.d script will initially start as root, and then su to the correct user ID, as configured in nexus.vmoptions.

For systemd configuration details see here:

Hi, thanks for your response. I use the init.d script. When using the command sudo service nexus start it starts and gives the following output:
ftrezza@ats-cld-srv-04:~$ sudo service nexus status
● nexus.service - LSB: nexus
Loaded: loaded (/etc/init.d/nexus; generated)
Active: active (exited) since Tue 2019-09-24 20:16:33 UTC; 20h ago
Docs: man:systemd-sysv-generator(8)
Process: 2026 ExecStart=/etc/init.d/nexus start (code=exited, status=0/SUCCESS)

Sep 24 20:16:32 ats-cld-srv-04 systemd[1]: Starting LSB: nexus…
Sep 24 20:16:33 ats-cld-srv-04 su[2026]: Successful su for nexus by root
Sep 24 20:16:33 ats-cld-srv-04 su[2026]: + ??? root:nexus
Sep 24 20:16:33 ats-cld-srv-04 su[2026]: pam_unix(su:session): session opened for user nexus by (uid=0)
Sep 24 20:16:33 ats-cld-srv-04 systemd[1]: Started LSB: nexus.

so it appears to be running as the nexus user, however the java process isn’t running and port 8081 isn’t listening.

Did you symlink the bin/nexus script to /etc/init.d/nexus? That is needed, it won’t work if you copy it.

If it is a symlink, I suggest running “/etc/init.d/nexus run” when logged in as user “nexus”, that will print the startup to the console so you can see what is wrong.

looks like the /opt/sonatype-work directory had some permissions issues. I just did a chown -R nexus on the folder and I think it’s resolved now. Thanks

So maybe I spoke too soon. I can run it as the nexus user but the service at startup still shows the process as exited.

ftrezza@ats-cld-srv-04:~$ service nexus status
● nexus.service - LSB: nexus
Loaded: loaded (/etc/init.d/nexus; generated)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)

It is symlinked. I don’t understand why it works fine as the nexus user but not when starting the service at boot or even after with service nexus start. The init.d script runs fine as the nexus user.