Rebooting is a fundamental administrative task for any Linux system, yet it’s often misunderstood or misused. Whether you’re maintaining a cloud server, running Ubuntu on your laptop, or scripting an automated restart, understanding how to properly reboot your system is crucial for system stability and data integrity.
This comprehensive tutorial will:
reboot
command and its alternativesreboot
Command in Linux?The reboot
command in Linux is a system utility that initiates a clean restart of the operating system. It’s a crucial tool for system administrators when:
If you’re new to Linux commands, you might want to start with our guide on Introduction to the Linux Terminal to understand the basics of command-line operations.
reboot [OPTION]...
sudo reboot
This is the most common form of the command. It tells the system to reboot immediately. You’ll typically need sudo
privileges to execute this. For a quick reference of other essential Linux commands, check out our Linux Commands Cheat Sheet.
To reboot from the terminal, use any of the following methods:
sudo reboot
Or:
sudo shutdown -r now
Or, using systemctl
:
# Method 1: Using reboot command
sudo reboot
# Method 2: Using shutdown command
sudo shutdown -r now
# Method 3: Using systemctl (modern systems)
sudo systemctl reboot
Each method has its advantages:
Method | Best For | Notes |
---|---|---|
reboot |
Quick, immediate restarts | Simple and direct |
shutdown -r |
Scheduled reboots | Can notify users and set delays |
systemctl reboot |
Modern Linux systems | Integrates with systemd services |
You can enhance the reboot
command with specific flags:
Option | Description |
---|---|
-f |
Force immediate reboot without shutdown |
--help |
Display help information |
--no-wall |
Suppress warning broadcast to logged users |
Example:
sudo reboot -f
Warning: The -f
flag forces an immediate reboot without running normal shutdown procedures. This can lead to:
shutdown
to RebootYou can reboot using the shutdown
command with the -r
flag:
sudo shutdown -r +5
This schedules a reboot in 5 minutes.
Or to reboot immediately:
sudo shutdown -r now
Related: Linux Commands Cheat Sheet
systemctl
to RebootModern systems using systemd
prefer:
sudo systemctl reboot
This method is clean and preferred on distributions like Ubuntu 20.04 and later.
Want to learn more about systemd?
Check out our comprehensive guide on How to Use systemctl to Manage Systemd Services and Units to master service management on modern Linux systems.
Sometimes, a regular reboot doesn’t work. In such cases:
sudo reboot -f
Or:
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
Caution: Force reboots should be your last resort. They don’t allow the OS to clean up processes or flush disk buffers.
Before rebooting your Linux system, it’s crucial to follow these essential steps to ensure a smooth and safe restart:
Check Running Processes
Identify any critical processes that might be affected by the reboot:
ps aux | grep important_process
This command shows all running processes and filters for specific ones. Replace important_process
with the name of any critical service or application you want to monitor. For more process management commands, refer to our Linux Commands Cheat Sheet.
Notify Users
Inform all logged-in users about the upcoming reboot to prevent data loss:
wall "System will reboot in 5 minutes for maintenance"
The wall
command broadcasts a message to all users’ terminals. Consider adjusting the time based on your system’s needs.
Check System Status
Verify the health of your system services and check for any errors:
systemctl status
journalctl -xe
systemctl status
shows the state of all systemd servicesjournalctl -xe
displays recent system logs with detailed error informationFor detailed information about managing systemd services, refer to our guide on How to Use systemctl to Manage Systemd Services and Units.
Verify Disk Space
Ensure you have sufficient disk space before rebooting:
df -h
This command shows disk usage in human-readable format. Look for partitions that are near capacity (above 90%).
Backup Critical Data
Create backups of important files before rebooting:
# Example: Backup important files
tar -czf backup.tar.gz /path/to/important/files
The tar
command creates a compressed archive. Replace /path/to/important/files
with the actual paths you need to backup.
# After updating packages
sudo apt update && sudo apt upgrade
sudo reboot
# Connect to server
ssh user@server_ip
# Check system status
uptime
systemctl status
# Perform reboot
sudo reboot
#!/bin/bash
# Example script for scheduled maintenance
logger "Starting scheduled maintenance reboot"
wall "System maintenance in 5 minutes"
sleep 300
sudo reboot
For more advanced service management and automation with systemd, including how to create and manage custom services, check out our comprehensive guide on How to Use systemctl to Manage Systemd Services and Units.
# Only use when necessary
sudo reboot -f
reboot
Doesn’t WorkInstall it with:
sudo apt install systemd-sysv # For Debian/Ubuntu
Or use:
sudo systemctl reboot
You likely need sudo
or root access.
Feature | reboot |
shutdown -r now |
---|---|---|
Default behavior | Immediate reboot | Scheduled or immediate |
Flexibility | Limited options | Schedule reboot easily |
Messaging users | Notifies users | More flexible with wall |
Use shutdown
for more control and user notification. Use reboot
for quick actions.
init 6
for RebootIn SysV systems:
sudo init 6
This is outdated and not recommended on modern systems using systemd
.
logger "Rebooting system due to XYZ"
. For a comprehensive list of logging and system commands, see our Linux Commands Cheat Sheet.A: There are several methods to reboot a Linux server from the terminal:
# Method 1: Using reboot command
sudo reboot
# Method 2: Using shutdown command
sudo shutdown -r now
# Method 3: Using systemctl (modern systems)
sudo systemctl reboot
Each method has its use case:
reboot
is quick and straightforwardshutdown -r
offers more control over timing and user notificationssystemctl reboot
is preferred on modern systemd-based distributionsreboot
and shutdown -r now
?A: While both commands achieve the same end result, they have different features:
reboot
is simpler and designed for immediate restartsshutdown -r
offers more flexibility:
shutdown -r +5
for 5 minutes later)A: Follow these steps for a safe production server reboot:
Notify users and stakeholders
wall "Server maintenance scheduled in 10 minutes"
Check system status
systemctl status
uptime
df -h
Schedule the reboot with notification
sudo shutdown -r +10 "Server maintenance"
Monitor the reboot process
journalctl -f
Verify services after reboot
systemctl status
# View logs from logger command
journalctl -t logger
# Or check system logs for reboot entries
grep reboot /var/log/syslog
A: If a normal reboot fails, follow this troubleshooting sequence:
First, try alternative reboot methods:
sudo shutdown -r now
sudo systemctl reboot
Check for hung processes:
ps aux | grep -i "D"
Check system logs:
journalctl -xe
# Check reboot-related logs
journalctl -t logger
grep reboot /var/log/syslog
As a last resort, use force reboot:
sudo reboot -f
If all else fails, use the magic SysRq key:
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
A: You can automate server reboots using several methods:
Using cron for scheduled reboots
# Add to crontab
0 3 * * 0 root /sbin/shutdown -r +5 "Weekly maintenance"
Using systemd timer
# Create a timer unit
[Unit]
Description=Weekly Reboot
[Timer]
OnCalendar=Sun 03:00
Persistent=true
[Install]
WantedBy=timers.target
Using a shell script
#!/bin/bash
logger "Starting scheduled maintenance"
wall "System maintenance in 5 minutes"
sleep 300
sudo reboot
Remember to:
Always notify users before automated reboots
Choose maintenance windows during low-traffic periods
Monitor the reboot process
Have a rollback plan if issues occur
Check logs after automated reboots:
# View maintenance logs
journalctl -t logger
# Check system logs for reboot entries
grep reboot /var/log/syslog
A: Yes, you need sudo privileges to use the reboot command. This is because rebooting is a system-level operation that affects all users and processes on the machine. Standard users don’t have the necessary permissions to initiate a system reboot for security reasons. To reboot your system, you’ll need to use sudo:
A: Before rebooting:
sudo shutdown -r +1
To give time for a clean restart.
reboot
isn’t working?A: Try shutdown -r now
or systemctl reboot
. If that fails, check for file system errors, hung processes, or permission issues. As a last resort, a forced reboot (reboot -f
) can be used, though it may cause data loss.
The linux reboot command
is simple yet powerful. It’s essential for performing system maintenance, applying updates, or resolving system-level errors. Whether you’re rebooting manually, automating restarts, or maintaining remote cloud servers, understanding the nuances of Linux rebooting commands will help you maintain stability and avoid common pitfalls.
For a deeper understanding of Linux command-line operations, check out our Introduction to the Linux Terminal guide, which covers essential concepts like environment variables, command execution, and shell navigation.
Continue Learning:
How to Use systemctl to Manage Systemd Services and Units
Linux Commands Cheat Sheet
Ready to master system administration?
Explore more in our Introduction to the Linux Terminal and level up your command-line skills today.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.