Ubuntu – When we enable any service using systemctl, in which runlevel would that service run

servicessystemd

As far as I know when we boot Linux system the services mentioned in runlevels (rcX.d) would be started.

If we enable any service to start during boot-up using systemctl command then will that service will be added to that default runlevel?

Best Answer

Actually no, it does not but you can run:

systemctl show -p WantedBy service-name

to find that in which target it would be run, for example:

systemctl show -p WantedBy tlp.service 
WantedBy=multi-user.target

which indicates that if I enable tlp it would be started when I get into multi-user.target.

Also worth to mention that run-levels are deprecated and systemd uses target instead:

┌─────────┬───────────────────┐
│Runlevel │ Target            │
├─────────┼───────────────────┤
│0        │ poweroff.target   │
├─────────┼───────────────────┤
│1        │ rescue.target     │
├─────────┼───────────────────┤
│2, 3, 4  │ multi-user.target │
├─────────┼───────────────────┤
│5        │ graphical.target  │
├─────────┼───────────────────┤
│6        │ reboot.target     │
└─────────┴───────────────────┘