Guidance Requested: GUI Reboot vs. Command Line Reboot

I’m wondering whether rebooting from the command line carries any inherent risk in comparison to rebooting from the GUI (I’m using KDE Plasma, but I think this question is DE agnostic).

It is so much easier to update my system from CLI and then issue the ‘reboot’ command, than to futz around with extra steps to run from the GUI. But, I wonder whether the GUI command is safer in the way of closing files/ applications or something similar, versus what the reboot command does.

I hope this makes sense. It is a total newbie question, but in searching, I don’t see a definitive answer as to the relative safety between the methods.

I’ll look forward to any thoughts / other considerations …

Cheers,

Barry

Hi there,

I am by no means an expert, but I would say there is no difference, I always reboot from cli, install / remove, update, etc. from cli.

If anything, I would bet the cli is way safer than any GUI.

Laters.

1 Like

Used both ways many times–no difference that I can see.

1 Like

There shouldn’t be any difference. In either case, they should be invoking systemd to shutdown/reboot the system.

I use the command line method 99% of the time.

3 Likes

I read that
systemctl reboot
systemctl poweroff
is the preferred way in the CLI. However, about 50% of the time I forget the systemctl part and haven’t had any problems.

Pudge

Thanks, everyone. I appreciate the feedback, confirmation, and shared experiences.

That is because of the package systemd-sysvcompat. It’s job is to take the old commands like reboot and and make them work. I think if you look you will see that the /usr/bin/reboot is actually linked to systemctl.

3 Likes

While @dalto is 99% of the time correct (a percentage much higher than mine, btw), I have to disagree here: there definitely is a difference between clicking on the button “Restart” in KDE Plasma and running the command reboot.

Rebooting from the CLI using the reboot command on KDE Plasma is generally safe, but will not save the current session properly because it won’t log you out (thus it won’t execute all the logout stuff Plasma does). If you want to do exactly what clicking on the GUI button does, only invoke it from the terminal, on KDE Plasma, the proper command is:

qdbus org.kde.ksmserver /KSMServer logout 0 1 1    

This will properly save your Plasma session, gracefully terminate your apps, log you out of your Plasma session, and then reboot (using the systemctl command). All of that will take a few seconds longer.

You can alias this to a more memorable command, like restart, by adding the following to your .bashrc or .zshrc:

alias restart="qdbus org.kde.ksmserver /KSMServer logout 0 1 1"
8 Likes

Good idea if you want to clean up after yourself. (mommy won’t!) :grin:

1 Like

Thank you, @Kresimir! This is a great, really useful tip.

Other than consulting with :frog::frog::frog:, where can one find this information? My goo-foo was weak this time …

I love this community!

2 Likes

Btw, I use duckduckgo. But the chances of finding it written out clearly and explained are not very high. Maybe somewhere in KDE documentation? No idea…

For me it took some experimenting to figure it out, and I did so only recently. I think I got the idea from someone on Stack Overflow or somewhere like that.

1 Like

Thanks for this cross-link! I promise, I searched the forum before posting this topic, but I totally missed your earlier post. I’m glad you linked it here, too.

1 Like

As @Kresimir said for KDE clicking the shutdown preserves the session.
This is KDE :slight_smile: so you can change this. See Desktop Session settings in System settings.
IIRC Restore previous session is the default.
For my home box, I use Start with and empty session so using cli to reboot makes no difference.
For my work box I use Restore previous session. It works up to a point. google-chrome doesn’t play ball with multiple desktops, firefox mostly does, well good enough that it doesn’t irk me.
I use a multiple desktops to hold the contexts for multiple tasks which are in progress.
This makes switching task context a bit easier for me.

It still does, only the difference is less noticeable. The reboot command just reboots your computer, without giving Plasma any chance to end the session. I don’t think that is unsafe to do, I never heard about it causing any problems to anyone, but it is definitely different.

For example, if you have any scripts in

~/.config/plasma-workspace/shutdown/

they won’t run if you reboot using the reboot command but will if you do it with the GUI button, or like I described above, using the qdbus command.

3 Likes

Works like a charm. Thanks for sharing your knowledge. Prompted by your various posts, I’ve been able to do some additional research and I’ve learned lots of great new info!

2 Likes