diff --git a/man/loginctl.xml b/man/loginctl.xml index 7f7252a5d9..fb51740503 100644 --- a/man/loginctl.xml +++ b/man/loginctl.xml @@ -312,7 +312,10 @@ This allows users who are not logged in to run long-running services. Takes one or more user names or numeric UIDs as argument. If no argument is specified, enables/disables - lingering for the user of the session of the caller. + lingering for the user of the session of the caller. + + See also KillUserProcesses= setting in + logind.conf5. @@ -410,6 +413,37 @@ otherwise. + + Examples + + + Querying user status + + $ loginctl user-status +fatima (1005) + Since: Sat 2016-04-09 14:23:31 EDT; 54min ago + State: active + Sessions: 5 *3 + Unit: user-1005.slice + ├─user@1005.service + ... + ├─session-3.scope + ... + └─session-5.scope + ├─3473 login -- fatima + └─3515 -zsh + +Apr 09 14:40:30 laptop login[2325]: pam_unix(login:session): + session opened for user fatima by LOGIN(uid=0) +Apr 09 14:40:30 laptop login[2325]: LOGIN ON tty3 BY fatima + + + There are two sessions, 3 and 5. Session 3 is a graphical session, + marked with a star. The tree of processing including the two corresponding + scope units and the user manager unit are shown. + + + diff --git a/man/logind.conf.xml b/man/logind.conf.xml index 597759e33a..10a23955a4 100644 --- a/man/logind.conf.xml +++ b/man/logind.conf.xml @@ -119,30 +119,45 @@ KillUserProcesses= - Takes a boolean argument. Configures whether - the processes of a user should be killed when the user - completely logs out (i.e. after the user's last session - ended). Defaults to no. + Takes a boolean argument. Configures whether the processes of a + user should be killed when the user logs out. If true, the scope unit + corresponding to the session and all processes inside that scope will be + terminated. If false, the scope is "abandonded", see + systemd.scope5, + and processes are not killed. Defaults to no. - Note that setting KillUserProcesses=1 + In addition to session processes, user process may run under the user + manager unit user@.service. Depending on the linger + settings, this may allow users to run processes independent of their login + sessions. See the description of enable-linger in + loginctl1. + + + Note that setting KillUserProcesses=yes will break tools like - screen1. + screen1 + and + tmux1, + unless they are moved out of the session scope. See example in + systemd-run1. + KillOnlyUsers= KillExcludeUsers= - These settings take space-separated lists of - usernames that influence the effect of - KillUserProcesses=. If not empty, only - processes of users listed in KillOnlyUsers= - will be killed when they log out entirely. Processes of users - listed in KillExcludeUsers= are excluded - from being killed. KillExcludeUsers= - defaults to root and takes precedence over - KillOnlyUsers=, which defaults to the empty - list. + These settings take space-separated lists of usernames that + determine to which users the KillUserProcesses= setting + applies. A user name may be added to KillExcludeUsers= to + exclude the processes in the session scopes of that user from being killed even if + KillUserProcesses=yes is set. If + KillExcludeUsers= is not set, the root user + is excluded by default. KillExcludeUsers= may be set to an + empty value to override this default. If a user is not excluded, + KillOnlyUsers= is checked next. A list of user names may be + specified in KillOnlyUsers=, to only include those + users. Otherwise, all users are included. diff --git a/man/systemd-run.xml b/man/systemd-run.xml index 7b7c9305fb..0d58356e00 100644 --- a/man/systemd-run.xml +++ b/man/systemd-run.xml @@ -394,6 +394,50 @@ Dec 08 20:44:48 container systemd[1]: Started /bin/touch /tmp/foo.# systemd-run -t --send-sighup /bin/bash + + + Start <command>screen</command> as a user service + + $ systemd-run --scope --user screen +Running scope as unit run-r14b0047ab6df45bfb45e7786cc839e76.scope. + +$ screen -ls +There is a screen on: + 492..laptop (Detached) +1 Socket in /var/run/screen/S-fatima. + + + This starts the screen process as a child of the + systemd --user process that was started by + user@.service, in a scope unit. A + systemd.scope5 + unit is used instead of a + systemd.service5 + unit, because screen will exit when detaching from the terminal, + and a service unit would be terminated. Running screen + as a user unit has the advantage that it is not part of the session scope. + If KillUserProcesses=yes is configured in + logind.conf5, + the default, the session scope will be terminated when the user logs + out of that session. + + The user@.service is started automatically + when the user first logs in, and stays around as long as at least one + login session is open. After the user logs out of the last session, + user@.service and all services underneath it + are terminated. This behaviour is the default, when "lingering" is + not enabled for that user. Enabling lingering means that + user@.service is started automatically during + boot, even if the user is not logged in, and that the service is + not terminated when the user logs out. + + Enabling lingering allows the user to run processes without being logged in, + for example to allow screen to persist after the user logs out, + even if the session scope is terminated. In the default configuration, users can + enable lingering for themselves: + + $ loginctl enable-linger +