67

I know how to enable/disable lingering with loginctl.

But up to now I found no way to query the status of a user.

I want to know: Is lingering enable for user foo?

How can I access this information?

guettli
  • 3,811

4 Answers4

86

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
Markus Kuhn
  • 1,231
30

loginctl user-status foo shows linger status.

21

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

loginctl show-user "$USER" --property=Linger | grep -q 'yes'
Xorax
  • 368
1

systemd v252 (check version with loginctl --version) introduced an additional LINGER column for the output of loginctl list-users.

Example output:

$ loginctl list-users
 UID USER   LINGER
1000 abdull yes
1001 guest  no

2 users listed.

Abdull
  • 227