systemd: how to get current target

Glenn Holmer shadowm at lyonlabs.org
Wed Dec 24 15:34:33 UTC 2014


On 12/24/2014 09:09 AM, Sérgio Basto wrote:
> cd /etc/systemd/system
> ll default.target
> lrwxrwxrwx 1 root root 36 Dez 24 15:07 default.target
> -> /lib/systemd/system/graphical.target

Yeah, I get that this is the default target. What I want to know is,
what's the *current* target, i.e. what's the systemd way of querying
runlevel. I understand that the concept doesn't apply exactly in
systemd, so a better way to ask might be "of those targets which
correspond to runlevels, which is the highest one that's running?"

For example, normally "systemctl list-units --type=target" shows both
multi-user and graphical running, but after "systemctl isolate
multi-user.target", graphical is no longer listed (adding --all shows it
as "inactive").

I suppose you could hack up a script based on the runlevel* symlinks in
/usr/lib/systemd/system, but surely there's a better way?

-- 
Glenn Holmer (Linux registered user #16682)
"After the vintage season came the aftermath -- and Cenbe."


More information about the kde mailing list