Preventing systemd –user from launching

My friend Yari came to me this morning with a small challenge: How to create a temporary user on a GNU/linux system preventing the systemd --user from launching for that user upon login.

According to pam_systemd(8), user@.service is the one running systemd --user

So, we can accomplish what is needed by masking the aforementioned service just before the actual login:

sudo systemctl mask user@.service

Now login as the new user to perform some tasks. Once the login is complete, we can unmask the service, to leave things as they were:

sudo systemctl unmask user@.service
Tags systemd
pancho horrillo
I do things with computers.