16.04 Command to list all services started on boot

Solution 1:

As far as I now, services are automatically enabled in Ubuntu, so when you install something like Apache it will be started at boot.

Find some information

To find out all services that have been run at startup:

systemctl list-units --type service

this will show all services that has been loaded at boot and are active now. If you want to get a list of all services no matter they are active or not:

systemctl list-units --type service --all

Another thing you can do is to run:

systemctl list-dependencies --type service

then hit / and search for mongodb see what service/target depends on it and runs it.

Also you can run :

locate mongodb.service

Which produces something like:

/lib/systemd/system/multi-user.target.wants/mongodb.service

then you will know that it's being started as a part of multi-user target, alternative to this is:

$ systemctl cat mongodb.service | grep -i wantedby
WantedBy=multi-user.target

Disable it

To find out that if it's active (Will be run at startup/boot-time):

systemctl is-active mongodb

It's either active or inactive; In your case it should be active.

To stop it from being started at boot time we should disable it:

sudo systemctl disable mongodb

And to make sure nothing else (No other service) can start it, we mask it:

systemctl mask mongodb

so it will be linked to /dev/null and can't be started automatically or manually anymore.

I'm not aware of mongodb service name, try hitting the tab it will be completed. I guess it's mongodb ;)

Solution 2:

To know if a service is enabled at boot time, the right command is :

systemctl is-enabled apache2
enabled

You can try by yourself by changing the state with

systemctl enable apache2
systemctl disable apache2

(this isn't intended to be the answer)

Solution 3:

Also have a look at Settings -> Session and Startup -> Application Autostart to see if your application is mentioned there.