loginctl enable-linger/disable-linger ... but reading linger-status?

You can show a list of lingering users with

ls /var/lib/systemd/linger

because

loginctl enable-linger $USER
loginctl disable-linger $USER

do the equivalent of

touch /var/lib/systemd/linger/$USER
rm /var/lib/systemd/linger/$USER

loginctl user-status foo shows linger status.


The best I found for check it in scripts (programmatically):

loginctl show-user $USER --property=Linger 2>/dev/null | grep -q 'yes'