6-Ways to shutdown RockyLinux from the command-line

Rocky Linux is a free, open-source enterprise operating system that serves as a community-driven successor to CentOS, particularly CentOS 8, after its shift to CentOS Stream. Founded by Gregory Kurtzer, the original co-founder of CentOS, Rocky Linux is designed to be a stable, production-ready platform compatible with Red Hat Enterprise Linux (RHEL). It offers a robust and reliable environment for servers, development, and various enterprise applications, with long-term support and regular updates to ensure security and performance. Rocky Linux has quickly gained popularity among users seeking a reliable, community-maintained alternative to RHEL that offers continuity and compatibility in enterprise environments.

Shutting down a Rocky Linux system can be done using several different commands via the command-line interface (CLI). Each method provides flexibility depending on your needs and preferences. Below are the steps and alternative methods to shut down a Rocky Linux system.


Method 1: Using the shutdown Command

The shutdown command is the most commonly used command to shut down a Linux system.

  1. Open the Terminal:
    • Access the command line by opening the terminal. This can be done from your desktop environment or via SSH if you are connected remotely.
  2. Execute the Shutdown Command:
    • To shut down the system immediately, type the following command and press Enter:
      sudo shutdown now
    • You will be prompted to enter your password. After that, the system will begin the shutdown process immediately.
  3. Alternative Timing Options:
    • To schedule a shutdown after a specific time period (e.g., 1 minute), use:
      sudo shutdown +1
    • To schedule a shutdown at a specific time (e.g., 10:00 PM), use:
      sudo shutdown 22:00
  4. Cancel a Scheduled Shutdown:
    • If you’ve scheduled a shutdown and want to cancel it, run:
      sudo shutdown -c

Method 2: Using the poweroff Command

The poweroff command is another straightforward way to shut down the system.

  1. Execute the Poweroff Command:
    • To power off the system immediately, type:
      sudo poweroff
    • This command effectively shuts down the system immediately, similar to shutdown now.

Method 3: Using the halt Command

The halt command can also be used to stop all processes and halt the system.

  1. Execute the Halt Command:
    • To halt the system, use:
      sudo halt
    • Note that while this command stops all processes, it might not completely power off the machine, depending on your system’s configuration.

Method 4: Using the init Command

The init command can change the runlevel of the system. Runlevel 0 is used to shut down the system.

  1. Execute the Init Command:
    • To shut down the system using init, type:
      sudo init 0
    • This will change the runlevel to 0, which initiates the shutdown process.

Method 5: Using the systemctl Command

With the advent of systemd in many Linux distributions, including Rocky Linux, systemctl is a powerful command to manage system services.

  1. Execute the Systemctl Command:
    • To shut down the system, use:
      sudo systemctl poweroff
    • Alternatively, you can use:
      sudo systemctl halt
    • Or to reboot instead of shutting down, use:
      sudo systemctl reboot

Method 6: Using the reboot Command

While primarily used to reboot, the reboot command can also power off the system by specifying an option.

  1. Execute the Reboot Command:
    • To shut down (instead of rebooting), use:
      sudo reboot --poweroff
    • This will initiate the shutdown process.

Conclusion

Each of these methods provides a way to safely shut down a Rocky Linux system from the command line. Depending on your specific needs – whether you want an immediate shutdown, a scheduled shutdown, or you simply prefer one command over another – you have multiple options to choose from. Remember to save all your work before shutting down the system to avoid data loss.