Skip to main content
24 votes
Accepted

Prevent Logoff from Killing tmux Session

This "feature" has existed in systemd previously, but the systemd developers decided to effect a change in the default, to enable the setting for termination of child processes upon log out of a ...
palswim's user avatar
  • 5,657
20 votes

System service running as user is terminated on logout

For me the solution was loginctl enable-linger username. Without this the service would die when the user logged out. https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-...
burneddi's user avatar
  • 330
9 votes
Accepted

Where is TMOUT being set in CentOS 7? How can I disable it?

To disable the time out I changed the file /etc/profile.d/local.sh. I commented out lines that were setting the timeout variable and making it readonly. vi /etc/profile.d/local.sh #export TMOUT=43200 ...
PatS's user avatar
  • 644
7 votes
Accepted

System service running as user is terminated on logout

You can change logind configuration: /etc/systemd/logind.conf [Login] … KillUserProcesses=no … This also changes behavior for other services and background processes (like screen, tmux). See issue #...
jiwopene's user avatar
  • 1,101
4 votes

How to run a command every time that I exit a zsh shell (including non-login shells)

Add a function like function shellExit { # Your commands } along with a trap such as trap shellExit EXIT in .zshrc
Shining Trapezohedron's user avatar
3 votes

Issue with SSH Client Alive Interval in sshd_config

ClientAlive* are not designed to terminate healthy connections. It's a myth they are. Please read this other answer of mine to learn what the options are really for. In a nutshell, they are for: ...
Kamil Maciorowski's user avatar
3 votes
Accepted

How to log out all inactive terminal sessions in GNU/Linux?

TMOUT causes idle interactive shells to exit, it doesn’t close desktop sessions. If you don’t want to have to remember to log out from your “rescue” VTs, it seems like a good solution to me: your ...
Stephen Kitt's user avatar
3 votes

Gracefully close chrome on shutdown

killall chrome --wait worked for me
Oleg Apostol's user avatar
3 votes

Prevent Logoff from Killing tmux Session

The missing bit can be found on SU: First: Keep the $USER's SystemD instance running after logoff: sudo loginctl enable-linger $USER Second: Reboot. (According to man loginctl this becomes ...
Tino's user avatar
  • 1,287
3 votes

How to reboot/shut down gracefully in Awesome WM?

wmctrl may help you (package name wmctrl). wmctrl helps you interact with a EWMH/NetWM compatible X Window Manager. I'm not sure is AwesomeWM fits this description, but if it does, this answer would ...
Stewart's user avatar
  • 16k
3 votes
Accepted

How to log myself out of ssh, from a bash script?

If you want to logout after the successful completion of /path/to/shell-script.sh, use: /path/to/shell-script.sh && logout A ruder way to do it would be to have the script kill the parent: ...
Jeff Schaller's user avatar
  • 68.8k
2 votes
Accepted

Which file is read and executed when interactive non-login bash session exits?

None. To have the interactive non-login shell source a file upon exiting, set a trap in .bashrc: shopt -q login_shell || trap '. "$HOME/.bash_non-login_logout"' EXIT
Kusalananda's user avatar
  • 356k
2 votes

How to close XServer session via command

I just run killall xinit I don't put anything into $$ because bash uses $$ for the pid of the shell.
B Phillips's user avatar
2 votes
Accepted

Does exiting a login shell necessarily log out of the OS?

In bash speak, "login shell" means a shell invoked with the -l flag, or where the first character of argument 0 begins with a -. (See man bash INVOCATION section). In your example, you can see ...
Stephen Harris's user avatar
2 votes

What processes can survive logging out of Linux, and what not?

I don't know how systemd (especially /usr/lib/systemd/systemd-logind) is involved in OS logout process. Following is my partial answers: The login process wait() on the login shell process, and ...
Tim's user avatar
  • 107k
2 votes
Accepted

How to run a command every time that I exit a zsh shell (including non-login shells)

There's an example in this zsh guide which sources ~/.zlogout for non-login shells using the TRAPEXIT function. This seems to be exactly what you want. TRAPEXIT() { # commands to run here, e.g. if ...
Freddy's user avatar
  • 26.3k
2 votes

What is the meaning and command executed on Ctrl+Alt+Del in Linux?

The Linux kernel can either hard reboot or send SIGINT the init process upon Ctrl + Alt + Del The Linux kernel itself allows two possible behaviors from Ctrl-Alt-Del: reboot immediately send SIGINT ...
Ciro Santilli OurBigBook.com's user avatar
2 votes
Accepted

How to run script on XFCE4 logon and logoff?

Settings -> Session and Startup -> Application Autostart
Artem S. Tashkinov's user avatar
1 vote

Automatic log out while working in Cent OS Stream 8

my two cents: you may need to set the environment variable TMOUT to 0 into the system file /etc/profile.d/local.sh for further info you can read this question and the accepted answer. (while for ...
sigmud's user avatar
  • 184
1 vote

Mounting directories on demand or until logged

Regarding a possible solution resorting to some logout script, LighDM conforms to the freedesktop specification which, given this setting : [SeatDefaults] … session-cleanup-script=command … Will ...
MC68020's user avatar
  • 8,637
1 vote

Logout other users from KDE/plasma as root

OK, figured it out: su -c "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/<numerical-user-id>/bus qdbus org.kde.ksmserver /KSMServer logout 0 3 2" "<username>"
Torsten Crass's user avatar
1 vote

Challenge: unable to logout of linux

type exit Press Ctrl + D kill or kill -9 your_shell_PID poweroff which will technically log you out Unplug from the mains Blow it all up Cut all the wires
Artem S. Tashkinov's user avatar
1 vote
Accepted

Debian: logging out causes services to become unavailable

Almost a year later. You solve this by modifying /etc/systemd/logind.conf setting KillUserProcesses=yes. It still takes around 15 seconds to terminate all the processes of the session, but they stop ...
mathbekunkus's user avatar
1 vote

How to restrict a user from using tty?

You can add entries to /etc/security/access.conf which disallow logins to the TTYs like so: -:ALL EXCEPT root There's other examples in this file if you're looking for additional use cases. NOTE: The ...
slm's user avatar
  • 380k
1 vote

Execute script prior to cinnamon logout (unsing MDM or other display manager)

If you switch to LightDM as I was suggesting, then it should be simple. Set the following parameter in the config file: /etc/lightdm/lightdm.conf session-cleanup-script = Script to run when quitting ...
Vlastimil Burián's user avatar
1 vote

What is the meaning and command executed on Ctrl+Alt+Del in Linux?

Contemporary Linux distros use systemd instead of SysV init. Behaviour of ctrl-alt-delete combo is handled by ctrl-alt-del.target, which is by default linked to reboot.target, but could be set to any ...
Tomasz Pala's user avatar
1 vote

Execute code in a logout script if exiting from a particular directory?

I like many of my shell scripts portable and shell-agnostic, so I prefer trapping EXIT over using the bash-specific .bash_logout method. And for a truly self-contained solution it's best not having to ...
volkerk's user avatar
  • 11

Only top scored, non community-wiki answers of a minimum length are eligible