What is the recommended way to reboot via the CLI under GNOME?

Although on all modern distributions, systemctl reboot is available (and OpenRC, etcetera, do provide equivalents regardless), it’s not particularly kind to the DE: especially for GUI applications, it appears to send a SIGKILL. In this context, does an equivalent to KDE Plasma’s qdbus-qt6 org.kde.Shutdown /Shutdown org.kde.Shutdown.logoutAndReboot exist, wherein it prompts the user to force-close any uncooperative applications, or cancel the shutdown?

An example is undermentioned:

One reason I ask is because this appeared to once be advisable: [1]


  1. superuser.com/revisions/81090/1 ↩︎

Take a look at the gnome-session-quit command. With no options it triggers a logout, with --power-off it shuts down, and with --reboot it reboots. Under the hood, it shuts down GNOME in an orderly fashion, then triggers a systemctl reboot for you. It’s the same codepath as the GUI shutdown buttons in GNOME.

There’s also a DBus API if you want to do it programmatically, rather than on the command line. See Shutdown(), Reboot(), and Logout(). The gnome-session-quit command just talks to this DBus API for you

4 Likes

@adrianvovk, thanks for that. Unless you want to earn some points on SE yourself, I’ve posted it as an answer to some relevant SE questions, since I’ve yet to come across such a simple and comprehensive answer anywhere until now:

I’ve since ascertained that my premise wasn’t quite correct, but your information provided what I needed to know in order to file what I wanted to:

2 Likes