Linux – systemd : how to get the running target

centos7linuxsystemd

  • Command systemctl get-default returns user-defined.target.
  • Then I use systemctl isolate multi-user.target to switch to multi-user.target.
  • I can see that a bunch of services that shouldn't be running on user-defined.taret and should be running on multi-user are running, this implies I am on multi-user.target.
  • But, systemctl get-default always returns user-defined.target.

Question is, without looking and sorting through the services, how do I know that I am running on multi-user.target after using isolate ?

Best Answer

In systemd, there may be more than one active target at a time.

To inspect the list of all currently active targets:

systemctl list-units --type target --state active

To quickly find out whether a specific target (e.g. user-defined.target) is active or not:

systemctl is-active user-defined.target