๐ฅ Check out this trending post from Hacker News ๐
๐ **Category**:
๐ **What Youโll Learn**:
Killing Processes
One of the features of systemd that is most controversial is the option to kill user processes when the user logs out. That initially killed screen/tmux/nohup processes too. In recent Debian releases the default configuration of systemd-logind (the login manager for systemd) is to allow processes to keep running, the configuration file /etc/systemd/logind.conf has an option KillUserProcesses that can be enabled to have user processes killed. If you do that then there are options to only kill processes for certain users and to exclude some users (default to excluding root). If using that option you can apparently use a systemd unit to start screen which prevents it being killed on logout.
This is a very handy feature for some particular user cases. One situation was that I was supporting some people who werenโt very good at computers on a system running KDE and some KDE processes would linger. So the option of logout and login again to deal with an issue of akonadi or some other KDE service misbehaving didnโt work. On that system I enabled the option to kill user processes which reduced the number of problems they had while not requiring rebooting.
It is widely believed that the โlingerโ feature is required to allow screen/tmux/nohup to work, in Debian (and probably most distributions) that is not the case. It might be that some combinations of configuration requires โlingerโ to allow screen/tmux to work but I am not interested in trying to discover them. Of all the people I have directly supported for Linux desktop use (which numbers in the hundreds) none of them have had the ability to use screen/tmux and also the cluelessnes that makes me want to automatically kill their processes when the logout.
Controlling Linger
You can enable and disable โlingerโ for your own account with the following commands if polkit is installed and in a typical configuration:
loginctl enable-linger loginctl disable-linger
If running as root you can enable and disable it for another user with the following commands:
loginctl enable-linger $ACCOUNT loginctl disable-linger $ACCOUNT
There doesnโt seem to be any documented way of discovering if an account has linger enabled or for listing accounts that have it, it seems that โls /var/lib/systemd/lingerโ is the only option.
Linger on Debian
On a Debian system with close to default settings the processes wonโt be killed on logout and the only difference โlingerโ makes is to start programs in the userโs context BEFORE they login. A friend was recently testing out a bunch of LLM programs on one of my servers and the account he used for that ended up with โlingerโ enabled, presumably one of the install scripts he ran was written on the assumption that enabling linger was necessary for nohup to work and it did so automatically without being asked.
One benefit Iโve found from this behaviour is on my laptop. Iโm currently testing out new SE Linux policy on my laptop and rebooting it a lot. When I enabled linger on my account it caused the laptop to connect to wifi on boot without needing to login which is convenient. I can then ssh to it even when the X11/Wayland login configuration is broken.
I will leave it enabled after finishing these tests. Having background processes like Pipewire and Bluetooth start before I login will presumably make things slightly faster when I do login.
๐ฅ **Whatโs your take?**
Share your thoughts in the comments below!
#๏ธโฃ **#Systemd #Linger #etbe #Russell #Coker**
๐ **Posted on**: 1785075809
๐ **Want more?** Click here for more info! ๐
