What are the steps to reboot a Linux server via SSH?

You can reboot a Linux server via SSH using a few simple commands. Here’s a breakdown of the process:

  1. Access your server via SSH

You have to open the terminal and type the command mentioned below:

ssh username@server_ip_address

  • Change the username with your actual username on the server.
  • Change server_ip_address with the server’s IP address or domain name.
  1. Execute the reboot command

Once you’re logged in, you can use one of the following commands to reboot the server:

  • sudo reboot: This is the most common and straightforward command. It requires sudo (superuser do) privileges, so you’ll likely be prompted for your password.
  • sudo shutdown -r now: This command uses the shutdown utility with the -r option for rebooting. Now specifies that the reboot should happen immediately.
  • sudo shutdown -r 0: Similar to the previous command, but uses 0 to indicate immediate reboot.
  1. Wait for the server to reboot

After executing the command, your SSH session will close, and the server will begin rebooting. You can use the ping command to monitor when the server comes back online:

ping server_ip_address

Important notes:

Permissions: You need appropriate permissions (usually sudo) to reboot the server.

Data loss: Rebooting the server will interrupt any running processes. You have to save your work before beginning.

Alternative: If you have root access, you can use the command /sbin/reboot directly.

Additional tips:

  • Scheduled reboot: You can schedule a reboot using the at or cron utilities.
  • Emergency reboot: Sometimes, you might need to force a reboot using sudo reboot -f. However, this should be used as a last resort as it can lead to data loss.

Leave a Reply