Shortcut to restart the system

I have become accustomed to using REISUB to restart the system instead of executing the commands sudo umount -l /mnt/* and reboot as I previously did. However, I have noticed that this method restarts the system abruptly. Is there an alternate shortcut available to restart the system gracefully when it is not frozen?

If it’s not “frozen”, the normal shutdown procedure
(no REISUB)
will take care of everything (unmounting included)
and the shutdown will be … graceful.

What makes you think this is not happening?

sudo umount -l /mnt/* && echo "PC will reboot in 10 seconds" && sleep 10 && reboot

:question:

Anyway, the reboot is gracefully, but fast. reboot is just enough.

A previous personal experience that was probably just a fluke. But I would like to know about a shortcut to make it faster anyways.

I don’t understand. That’s pretty much what I’m doing, but I want to use a shortcut instead.

I believe one of the graceful ways of rebooting is to use:
systemctl reboot

1 Like

You said: “However, I have noticed that this method restarts the system abruptly.” and that is the answer. It waits ten seconds until it reboots. Now it is not “abruptly”.

Anyway… the reboot command does all the unmounts already. Why would one think that this is needed?

I meant REISUB but yeah you are right it reads like that.

faster than this - your procedure ?:

… just say “reboot” - or “poweroff
These are the equivalent (the very same …) of:
systemctl reboot
or
systemctl poweroff

It doesn’t get faster than this - not even if you assign some keyboard shortcut to these commands.
You just save time typing with a keyboard shortcut - but it does not change anything about the sequence that will (gracefully) shut down/reboot your system.

1 Like

What is a graceful way to restart my system with a shortcut without abruptly shutting it down?

When I restart with systemctl reboot or reboot or with the GUI button I get a few errors on my hard drives saying Failed to unmount. Which is why those methods aren’t graceful to me.

I used to use sudo umount -l /mnt/* and reboot to avoid errors with my hard drives, but I’d like to use a keyboard shortcut instead for faster access. I’ve been using REISUB, but I’m not sure if it’s shutting down my system abruptly. I’m looking for a keyboard shortcut that uses similar commands as sudo umount -l /mnt/* and reboot or REISUB to gracefully restart my system.

It should be something like what ChatGPT hallucinates but I’m getting the error

No such schema “org.gnome.settings-daemon.plugins.media-keys”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”

Prompt: How can I reboot my system with a shortcut in Manjaro Linux?

There are different ways to reboot your Manjaro Linux system, and one of the easiest ways is to use a keyboard shortcut. Here are the steps to set up a shortcut to reboot your Manjaro Linux system:

  1. Open the Manjaro Linux application launcher by clicking on the “Start” button or pressing the Super key (usually the key with the Windows logo).
  2. Type “keyboard” in the search bar and click on “Keyboard” to open the Keyboard Settings.
  3. Click on the “Shortcuts” tab and then click on the “+” button to add a new shortcut.
  4. In the “Command” field, enter the command “systemctl reboot” (without the quotes).
  5. Click on “Set Shortcut” and then press the key combination you want to use as a shortcut for rebooting your system. For example, you can use Ctrl+Alt+R.
  6. Click on “Add” to add the new shortcut to the list of shortcuts.

Now you can use the keyboard shortcut you just created to reboot your Manjaro Linux system. Just press the key combination you selected, and your system will restart.

— ChatGPT

Prompt: Convert REISUB to commands I can write in the terminal. Use usual commands like reboot for Alt+ SysRq+B.

REISUB stands for a sequence of keys to perform a safe reboot of the system. Here are the equivalent commands that you can write in the terminal:

  1. “r” key - Switch the keyboard to raw mode.
echo 1 > /proc/sys/kernel/sysrq
  1. “e” key - Send the SIGTERM signal to all processes except init.
kill -TERM -1
  1. “i” key - Send the SIGKILL signal to all processes except init.
kill -KILL -1
  1. “s” key - Sync all mounted filesystems.
sync
  1. “u” key - Remount all mounted filesystems in read-only mode.
mount -o remount,ro -a
  1. “b” key - Reboot the system.
reboot

You can execute these commands in the given order to perform a safe reboot of the system, just like you would use REISUB.

— ChatGPT

Prompt: Write a bash script that adds the shortcut.

Sure, here’s a bash script that adds a keyboard shortcut to reboot your Manjaro Linux system::

#!/bin/bash

# Define the command to reboot the system
COMMAND="systemctl reboot"

# Define the shortcut key combination
KEYS="<Control><Alt>R"

# Create a desktop file for the script
cat <<EOF >~/Desktop/Reboot.desktop
[Desktop Entry]
Type=Application
Name=Reboot System
Exec=$COMMAND
Terminal=false
EOF

# Make the desktop file executable
chmod +x ~/Desktop/Reboot.desktop

# Set the shortcut using the gsettings command
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "$COMMAND"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "Reboot System"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "$KEYS"

Save this script as a file with a .sh extension, such as setup_reboot_shortcut.sh. Then, run the script by entering the following command in the terminal:

bash setup_reboot_shortcut.sh

After running the script, a “Reboot System” icon should appear on your desktop, and you should be able to use the Ctrl+Alt+R keyboard shortcut to reboot your Manjaro Linux system.

— ChatGPT

Prompt: Write a bash script that adds the shortcut using the commands like REISUB.

Here’s a bash script that adds a Ctrl+Alt+R shortcut to reboot Manjaro Linux using the REISUB commands:

  1. Create a new bash script and open it with your preferred text editor. For example, you can use the following command to create a new file named reboot-shortcut.sh:
nano reboot-shortcut.sh
  1. Copy and paste the following code into the file:
#!/bin/bash

# Add a Ctrl+Alt+R shortcut to reboot the system using REISUB

# Define the keyboard shortcut
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings \
"['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"

# Set the properties for the new custom shortcut
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ \
name 'Reboot System' \
command 'bash -c "echo 1 > /proc/sys/kernel/sysrq && kill -TERM -1 && kill -KILL -1 && sync && mount -o remount,ro -a && reboot"' \
binding '<Primary><Alt>r'

This script defines a new keyboard shortcut using the gsettings command. The shortcut uses the REISUB commands to safely reboot the system.

  1. Save the file and exit your text editor.
  2. Make the script executable using the following command:
chmod +x reboot-shortcut.sh
  1. Run the script using the following command:
./reboot-shortcut.sh

This will add the Ctrl+Alt+R shortcut to reboot Manjaro Linux using the REISUB commands.

  1. Test the new keyboard shortcut by pressing Ctrl+Alt+R. This should safely reboot your system.

— ChatGPT

Prompt: Use dconf write instead of gsettings and add a sleep between the commands.

Sure, here’s an updated bash script that uses dconf write instead of gsettings, and adds a sleep between the commands:

#!/bin/bash

# Define the command to reboot the system
COMMAND="mount -o remount,ro -a && sleep 1 && reboot"

# Define the shortcut key combination
KEYS="<Primary><Alt>r"

# Set the shortcut using the dconf command
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/name "'Reboot System'"
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/command "'$COMMAND'"
dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding "'<Primary><Alt>r'"

This script defines a new keyboard shortcut using the dconf write command. The shortcut uses the REISUB commands to safely reboot the system.

Save the script and make it executable using chmod +x reboot-shortcut.sh. Then run the script using ./reboot-shortcut.sh to add the new keyboard shortcut. You can test the shortcut by pressing Ctrl+Alt+R.

— ChatGPT

Don’t you have any GUI Desktop in use? :thinking:
AFAIK all GUI environments have a menu option to reboot or shutdown your computer :thinking:

Anyhow as mentioned by others, the command line version is just:

systemctl reboot

See man systemctl
:vulcan_salute:

Instead of fiddling around the problem, I would suggest finding the reason why it “failed to unmount”. Sometimes I saw such a message in the past, but the reason was that a program was writing or still accessing to it when I run poweroff. Obviously, it will fail to unmount properly. Or a program crash on power off and the kernel still assume that it accesses the mount point and blocks it (in that case it well never unmount properly).

 journalctl  --boot -1 --pager-end

PS: Believe me, on Windows, Volumes are also not always gracefully unmounted for reasons. But you never see it, because it is never a problem and the file system is correctable.

1 Like

Sidenote:

I will unwilling gag myself this time to reply to that part :rofl:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

I’m trying to write a script that adds reboot and shutdown shortcuts in Manjaro Cinnamon. Right now I’m getting:

❯ ./add_reboot_shortcut.sh
No such schema “org.gnome.settings-daemon.plugins.media-keys”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”
No such schema “org.gnome.settings-daemon.plugins.media-keys.custom-keybinding”

with the following script:

#!/bin/bash

# Define the command to reboot the system
COMMAND="sync && mount -o remount,ro -a && reboot"

# Define the shortcut key combination
KEYS="<Primary><Alt>r"

# Set the shortcut using the gsettings command
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "$COMMAND"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "Reboot System"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "$KEYS"

This isn’t what I want, I don’t want to clutter my desktop with these files, but just in case anybody else finds it useful.

To create custom keyboard shortcuts for both rebooting and shutting down your Manjaro Cinnamon system, you can modify the provided script as follows:

#!/bin/bash

# Define the commands to reboot and shutdown the system
REBOOT_COMMAND="systemctl reboot"
SHUTDOWN_COMMAND="systemctl poweroff"

# Define the shortcut key combinations
REBOOT_KEYS="<Primary><Alt>r"
SHUTDOWN_KEYS="<Primary><Alt>s"

# Create desktop files for the scripts
cat <<EOF >~/Desktop/Reboot.desktop
[Desktop Entry]
Type=Application
Name=Reboot System
Exec=$REBOOT_COMMAND
Terminal=false
EOF

cat <<EOF >~/Desktop/Shutdown.desktop
[Desktop Entry]
Type=Application
Name=Shutdown System
Exec=$SHUTDOWN_COMMAND
Terminal=false
EOF

# Make the desktop files executable
chmod +x ~/Desktop/Reboot.desktop
chmod +x ~/Desktop/Shutdown.desktop

This script creates two desktop files, one for rebooting and one for shutting down the system. The key combinations for rebooting and shutting down are set to Ctrl+Alt+R and Ctrl+Alt+S, respectively. You can change these key combinations by modifying the REBOOT_KEYS and SHUTDOWN_KEYS variables in the script.

After running the script, “Reboot System” and “Shutdown System” icons should appear on your desktop. You should be able to use the defined key combinations to reboot or shut down your system.

Please note that this script does not create global keyboard shortcuts but rather creates desktop files that can be executed with the specified key combinations. If you want to create global keyboard shortcuts, you may need to use Cinnamon’s built-in keyboard shortcut settings or a tool like dconf-editor to configure the shortcuts[6][12].

This seems like what I want but it doesn’t work, when I use the shortcut nothing happens. And when I call it from the terminal I see the same errors. So perhaps mount -o remount,ro -a doesn’t achieve the results I expected.

To create a keyboard shortcut that gracefully restarts your system, you can follow these steps:

  1. First, create a script that performs the desired actions. In your case, you want to sync the filesystem, remount it as read-only, and then reboot. Create a file called graceful_restart.sh and add the following content:
#!/bin/bash
sudo sync
sudo mount -o remount,ro -a
sudo systemctl reboot
  1. Make the script executable by running:
chmod +x graceful_restart.sh
  1. Move the script to a location in your $PATH, such as /usr/local/bin:
sudo mv graceful_restart.sh /usr/local/bin/
  1. Now, create a custom keyboard shortcut to run this script. Open the “Keyboard” settings in Manjaro Cinnamon, and navigate to the “Shortcuts” tab. Click on “Custom Shortcuts” and then click the “+” button to add a new shortcut.

  2. In the “Name” field, enter “Graceful Restart”, and in the “Command” field, enter graceful_restart.sh. Click “Add” to create the shortcut.

  3. Click on the “unassigned” button next to the new shortcut, and press the desired key combination to assign it as the shortcut for the graceful restart.

Now, when you press the assigned key combination, your system will execute the graceful_restart.sh script, which syncs the filesystem, remounts it as read-only, and then reboots your system gracefully.

Please note that this method requires you to enter your sudo password when the script is executed. If you want to avoid entering the password, you can configure sudoers to allow your user to run the script without a password. However, this can have security implications, so proceed with caution.

I checked again the logs to make sure but I don’t see the same that I see while the system shuts down.

To check shutdown logs in Manjaro, there are several options:

  • journalctl: This command can be used to read the system journal, which contains information about the shutdown process[1][6]. To view the log of the current boot session, use the command journalctl -b. To view the log from the last boot session, use the command journalctl -b -1 [2].

  • last: The last command can be used to display a list of the last reboot and shutdown entries[4][5]. To display the list of last shutdown entries, use the command last -x | grep shutdown.

  • manjaro-log-helper: This utility can be used to retrieve and upload logs graphically[3].

It’s important to note that the logs may be located in different directories depending on the application or service that caused the shutdown. For example, user logs may be located in ~/.local/share/, while system logs may be located in /var/log/ [3].

Moderator Edit: - Removed all Citations AI generated links! Please do not post such links again, and tone it down with the AI generated content on this forum!

You do realise, AI output is overcomplicated an buggy, do you. I am not at all sure you can define keyboard shortcuts as variables in that way. And maybe if you are a linux beginner you shouldn’t start your linux path with manjaro and even less with a community edition. Stick to xfce or kde at least…
On xfce you have at list at Keyboard Settings where you can add cutom shortcuts. You need no desktop files if you just want a key combo to shutdown (-r).

What is a graceful way to restart my system using a shortcut without abruptly shutting it down?

When I use commands like systemctl reboot or reboot, or even the GUI button, I encounter a few errors related to the failed unmounting of my hard drives. These methods are not graceful to me.

[FAILED] Failed unmounting /mnt/hdd7

Previously, I used the command sudo umount -l /mnt/* followed by a reboot to avoid errors with my hard drives. However, I would now prefer to use a keyboard shortcut for faster access. Currently, I have been using the REISUB method, but I’m uncertain if it abruptly shuts down my system. All I can confirm is that I don’t encounter any “Failed to unmount” errors this way. Therefore, I’m seeking a keyboard shortcut that allows me to gracefully restart my system, similar to the sudo umount -l /mnt/* and reboot method or the REISUB sequence.

dconf write /org/cinnamon/desktop/keybindings/custom-list "['custom0', 'custom1', 'custom2', 'custom3']"

dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom0/name "'Task Manager'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom0/command "'gnome-system-monitor'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom0/binding "['<Primary><Alt>KP_Delete']"

dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom1/name "'Kill Window'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom1/command "'xkill'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom1/binding "['<Primary>KP_Delete']"

# Define the commands to reboot and shutdown the system
REBOOT_COMMAND="kill -TERM -1 && kill -KILL -1 && sync && mount -o remount,ro -a && reboot"
SHUTDOWN_COMMAND="kill -TERM -1 && kill -KILL -1 && sync && mount -o remount,ro -a && shutdown now"

dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom2/name "'Reboot System'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom2/command "'$REBOOT_COMMAND'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom2/binding "'<Primary><Alt>r'"

dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom3/name "'Shutdown System'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom3/command "'$SHUTDOWN_COMMAND'"
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom3/binding "'<Primary><Alt>s'"

Am I using the variables REBOOT_COMMAND and SHUTDOWN_COMMAND correctly?

I’ve created the shortcut manually since the script doesn’t seem to work. Only the first command runs (kill -TERM -1).

If I change the shortcut to sync && mount -o remount,ro -a && reboot, it doesn’t seem to do anything.

Maybe I don’t have the necessary permissions to run the commands as they involve system-level operations.

Do you think systemd devs are so stupid they don’t know how to properly shutdown system?

What’s next? Will you reinvent the wheel, but instead of circle use ellipses?

Done, but 4 months old topic might be outdated, and since it has a solution applied, do you also want to remove that?