What is the cleanest way to exit/kill/logout linux session?

Viewed 1156

I am using tiling window managers and from time to time I want to go back to a normal desktop environment or switch to another tiling window manager.

Usually I use a rofi script with loginctl terminate-user $USER.

Before this I used pkill -9 -u $USER.

I also found other options such as loginctl kill-user $USER and pkill dwm or pkill i3.

With so many options, I started to wonder which is the best and cleanest way to exit a session?

1 Answers

To kill a window manager, you only need to kill the X server, leaving Linux and your login shell running.

For a general command, you can use:

 pkill -x X

In the specific case of i3, from i3's documentation:

To exit i3 properly, you can use the exit command, however you don’t need to (simply killing your X session is fine as well).

Example:
bindsym $mod+Shift+e exit

Related