10 Essential Methods to Reboot Your Ubuntu Server

Rebooting an Ubuntu server is a routine task for administrators, ensuring the system runs smoothly after updates, changes, or when troubleshooting issues. It’s crucial to understand various methods to reboot your server, each suited for different scenarios. This guide covers 10 methods to reboot your Ubuntu server, ensuring you’re equipped for any situation.

In this tutorial you will learn:

  • How to reboot your Ubuntu server from the command line
  • Using graphical interfaces to restart your server
  • Advanced reboot methods, including scheduled reboots and using web-based control panels
10 Essential Methods to Reboot Your Ubuntu Server
10 Essential Methods to Reboot Your Ubuntu Server
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Server
Software No specific software required
Other Access to a terminal or command line interface
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

10 Ways to Reboot Your Ubuntu Server

Understanding different methods to reboot your server allows for flexibility and efficiency in managing your system. Here are 10 ways to reboot your Ubuntu server:

  1. Reboot Command: The simplest way to reboot your server
    $ sudo reboot

    This command sends a reboot signal to the system, initiating a graceful restart. A graceful restart means that the system will attempt to close all running processes and applications in an orderly manner, saving any unsaved data where possible, before actually rebooting. This ensures minimal risk of data loss and maintains system integrity during the reboot process.

  2. Shutdown Command: A versatile approach to manage system power state, including reboot
    $ sudo shutdown -r now

    This command initiates an immediate shutdown followed by a reboot, leveraging the “-r” option to specify the reboot action. For scheduled reboots, the command can be adjusted to include a time parameter, such as +10, indicating a reboot in 10 minutes. For instance, sudo shutdown -r +10 "Rebooting in 10 minutes for maintenance" schedules the reboot 10 minutes from the command’s execution, with a broadcast message to logged-in users about the reason. The now parameter can be replaced with a specific time (e.g., 23:00) to schedule the reboot at that time. Additionally, the -c option can cancel a pending shutdown/reboot, allowing for flexible system management.

  3. REISUB: A safe way to reboot a frozen system
    Alt + SysRq + R, E, I, S, U, B

    This sequence is a safer way to reboot when the system is unresponsive. It sequentially switches to a raw keyboard mode, terminates processes, flushes filesystem caches, remounts filesystems read-only, and finally reboots.

    WHAT IS SysRq KEY?
    The SysRq (System Request) key is a special key on many computer keyboards, designed to provide direct communication with the operating system at a low level, bypassing the normal application and interface layers. On some keyboards, the SysRq function may be combined with the Print Screen (PrtScn) key, requiring users to press the Alt key (and sometimes the Fn key on laptops) in conjunction with the PrtScn/SysRq key to activate SysRq commands. This key’s primary modern use is with the Magic SysRq key feature in the Linux kernel, allowing users to perform a variety of system recovery and debugging tasks even when the system is unresponsive by entering specific key sequences. The actual appearance and labeling of the SysRq key can vary by keyboard and region, with some keyboards explicitly labeling it as “SysRq” or combining it with the “Print Screen” function, indicating its dual purpose.

  4. Systemctl Command: Using systemd’s control utility
    $ sudo systemctl reboot

    This command utilizes systemd to initiate a reboot, ensuring all systemd’s shutdown procedures are followed. The difference between systemctl reboot and traditional reboot commands (such as reboot or shutdown -r now) lies in how they interact with the system’s init system.

    While systemctl reboot specifically targets systemd, the system and service manager for Linux operating systems, ensuring a coordinated shutdown process, traditional reboot commands may bypass some of systemd‘s mechanisms. Using systemctl reboot ensures that all processes are notified of the shutdown, allowing them to terminate gracefully, and that systemd’s shutdown procedures, such as stopping all running services, unmounting file systems, and other cleanup tasks, are properly followed. This method is more integrated with systemd‘s ecosystem, providing a safer and potentially more consistent reboot process.

  5. Reboot from a Graphical Interface: For servers with a GUI installed
    Click on the power button, then select 'Restart'

    This may seem apparent, yet it’s worth mentioning. For Ubuntu servers equipped with a desktop environment, the graphical interface provides an option to reboot.

  6. Init Command: The traditional method for system V init
    $ sudo init 6

    Init 6 is the runlevel for rebooting a system, a method used in older versions of Ubuntu and other Linux distributions.

  7. Telinit Command: Similar to the init command
    $ sudo telinit 6

    This sends a signal to the init system to switch to runlevel 6, effectively rebooting the system.

  8. Using a Web-based Control Panel: For remote server management
    Log into your control panel and select 'Reboot'

    Many hosting services offer web-based control panels that allow you to reboot your server with a click.

  9. Scheduled Reboot: Implementing a one-time or periodic reboot schedule
    $ sudo shutdown -r 02:00

    This command configures the server for a one-time reboot at 2 AM, leveraging the system’s clock to determine the timing. For those needing to establish a recurring reboot schedule, utilizing cron jobs is an effective strategy. You can create a cron job by editing the crontab file for the root user with $ sudo crontab -e and adding a line such as 0 2 * * * /sbin/shutdown -r now, which instructs the system to reboot daily at 2 AM. This approach ensures that your server can automatically reboot at a specified frequency, enhancing system performance and stability through regular, clean startups.



  10. Using the Magic SysRq key: An emergency measure for systems that are completely unresponsive
    Cautionary Note on Using Magic SysRq for Emergency Reboots
    The command to force reboot the system using the Magic SysRq key should be used with extreme caution.
    $ echo b | sudo tee /proc/sysrq-trigger

    This command forces an immediate reboot of the system, bypassing the standard shutdown procedures like unmounting or syncing filesystems. It is a direct invocation of the Magic SysRq key functionality through the command line, where b stands for ‘reboot’.

    It’s crucial to understand that this method should be used only as a last resort, when all other attempts to revive or safely shut down the system have failed. The Magic SysRq key provides a range of other functions useful for system recovery, each triggered by echoing a different letter to /proc/sysrq-trigger. For instance, echo s | sudo tee /proc/sysrq-trigger syncs filesystems, and echo u | sudo tee /proc/sysrq-trigger remounts all mounted filesystems read-only, which can help prevent data corruption before a forced reboot.

Conclusion

Knowing multiple methods to reboot your Ubuntu server provides flexibility and ensures you can manage your server effectively under different circumstances. Whether you’re using the command line for a quick reboot, scheduling future reboots, or managing servers remotely through a web interface, each method has its place in a server administrator’s toolkit.