Several methods exist for restarting a Debian system from the command line. This guide outlines the most common and effective approaches.
Method 1: The reboot
Command
The simplest method is using the reboot
command. This requires root privileges:
sudo reboot
You'll be prompted for your password.
Method 2: The systemctl
Command
The systemctl
command, a powerful systemd tool, also offers a reboot function:
sudo systemctl reboot
This command also requires root access.
Method 3: The /sbin/reboot
Command
For an immediate, uninterruptible reboot, use this command:
/sbin/reboot
This command executes a reboot without delay.
Method 4: The shutdown
Command
The shutdown
command, primarily used for system shutdown, can initiate a reboot using the -r
flag. For an immediate reboot:
sudo shutdown -r now
To schedule a reboot in, for example, five minutes:
sudo shutdown -r 5
Method 5: The init
Command
The init
command manages run levels. Run level 6 initiates a reboot:
sudo init 6
Emergency Reboot: Magic SysRq Key
The Magic SysRq key offers a last-resort method for rebooting a frozen system. This is a kernel-level operation and should only be used in emergencies as it bypasses normal shutdown procedures. Use with caution, as data loss is possible. The process involves two commands:
echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger
Conclusion
Debian provides multiple command-line options for rebooting. Choose the method that best suits your needs and comfort level. Remember to use sudo
where necessary to execute commands with root privileges.
The above is the detailed content of The Art of Restarting Debian. For more information, please follow other related articles on the PHP Chinese website!