User Manager Systemd Service
User manager systemd service for K2 OnPremises Installation
Steps to add User Manager Systemd service
Design and Setup [Requires Root privileges]
Step 1 : Extract the linux user id of the chosen linux user.
Command to extract the UID for any user
id -u user_name
Sample Run :
id -u user_name
1000
Step 2 : Create the systemd service with the following name
vi /etc/systemd/system/user@UID.service
The UID corresponds to the user id of the linux user for which the service will run
Replace the UID with the value extracted in Step 1.
Sample Run :
vi /etc/systemd/system/user@1000.service
Step 3 : Place the following content in the file created in Step 2
[Unit]
Description=User Manager for UID %i
After=systemd-user-sessions.service
After=user-runtime-dir@%i.service
Wants=user-runtime-dir@%i.service
[Service]
LimitNOFILE=infinity
LimitNPROC=infinity
User=%i
PAMName=systemd-user
Type=notify
#PermissionsStartOnly is deprecated and will be removed in future versions of systemd
#This is required for all systemd versions prior to version 231
PermissionsStartOnly=true
ExecStartPre=/bin/loginctl enable-linger %i
ExecStart=-/lib/systemd/systemd --user
Slice=user-%i.slice
KillMode=mixed
Delegate=yes
TasksMax=infinity
Restart=always
RestartSec=15
[Install]
WantedBy=default.target
Step 4 : Enable and start the service
systemctl enable --now user@UID.service
Sample Run :
systemctl enable --now user@1000.service
Created symlink from /etc/systemd/system/default.target.wants/user@1000.service to /etc/systemd/system/user@1000.service.
Verification
In order to verify the service status, login to the machine with the chosen linux user via ssh, su, or any other mechanism.
Step 1 : Run the following command to set the XDG_RUNTIME_DIR environment variable.
export XDG_RUNTIME_DIR=/run/user/$(id -u)
Step 2 : Add the above export in the .bashrc/.bash_profile or other corresponding shell environment file based on your environment to set it permanently.
Step 3 : Check the service status.
systemctl --user status
Sample Run :
systemctl --user status
<97><8F> ip-192-168-5-5.us-west-1.compute.internal
State: running
Jobs: 0 queued
Failed: 0 units
Since: Thu 2021-09-09 06:57:49 UTC; 5 days ago
CGroup: /user.slice/user-1000.slice/user@1000.service
Last updated
Was this helpful?