Similarly to the answer previously mentioned you can use:
systemctl list-units --type target | egrep "eme|res|gra|mul" | head -1
What you get as a result is your current target.
If you have installed unit that has in its name one of these four strings above, you could add the ^
character in front of them - egrep "^eme|^res|^gra|^mul"
After I've read 'Eduard Rozenberg' post below I decided to edit my answer, actually to provide additional clarification.
I don't know if Eduard tried my solution before posting his answer.
However, if you use this command above you should get right results.
Eduard states that he gets both, graphical and multi-user target.
We should get both, graphical and multi-user targets only in GUI environment because graphical.target wants multi-user.target.
Head successfully resolves this showing only first line (graphical.target), because results are sorted alphabetically.
@Eduard Rozenberg - if you read this please provide feedback if this command works for you, thanks...
Also I would like to provide information for shorter command/typing:
- you can use
-t
instead of --type