How to shut down or reboot a Linux system from the command line?
Jun 21, 2025 am 12:49 AMTo correctly shut down or restart the Linux system, use the corresponding commands and pay attention to permissions and operation details. 1. Sudo shutdown -h now can be shut down immediately, or sudo shutdown -h 10 can be shut down regularly, and notification messages can be attached; 2. Sudo reboot or sudo shutdown -r now can be shut down. Before operation, you should save the work, confirm that no other users are online, ensure that the server can be connected remotely, and avoid frequent power outages. Master these key points to safely perform shutdown or restart operations.
Shut down or restarting the Linux system is not complicated. The key is to use the right command and pay attention to the current user permissions. The two most commonly used commands are shutdown
and reboot
, but how to use them and when depends on your actual scenario.
How to shut down correctly?
In Linux, ordinary users usually do not have permission to shut down directly and need to use sudo
permission to execute commands. The most common way is to use the shutdown
command:
- Turn off the power immediately:
sudo shutdown -h now
- Timely shutdown (for example, after 10 minutes):
sudo shutdown -h 10
Here -h
means halt (stop the system), now
means execution immediately. If you want to notify other logged in users in advance that the system will be closed soon, you can add a message, such as:
sudo shutdown -h 5 "System will shutdown in 5 minutes!"
How to quickly restart the system?
If you just want to restart instead of shutting down, you can use the reboot
command directly:
sudo reboot
This command is simple and direct, suitable for use after updating the kernel or service configuration. It will immediately terminate all processes and restart the system, so make sure there are no important tasks running.
You can also use the shutdown
command to restart:
sudo shutdown -r now
Here -r
means reboot.
What should you pay attention to before shutting down or restarting?
Although these commands may seem simple, improper operation may lead to data loss or file system corruption. The following points need to be noted:
- Save the ongoing work : the system will force the process to end after the command is executed, and unsaved data may be lost.
- Confirm that no other users are online : you can use the
who
command to check which users are currently logged in. - If it is a remote server, make sure to reconnect : especially after restarting, if there is a problem with the network or SSH configuration, you may lose control.
- Do not frequently power off instead of shutting down the power : unplugging the power supply or shutting down the virtual machine may cause damage to the system files.
Basically that's it. Remember a few common commands and cooperate with a little bit of care to safely shut down or restart.
The above is the detailed content of How to shut down or reboot a Linux system from the command line?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Linuxcanrunonmodesthardwarewithspecificminimumrequirements.A1GHzprocessor(x86orx86_64)isneeded,withadual-coreCPUrecommended.RAMshouldbeatleast512MBforcommand-lineuseor2GBfordesktopenvironments.Diskspacerequiresaminimumof5–10GB,though25GBisbetterforad

Written in C, MySQL is an open-source, cross-platform, and one of the most widely used Relational Database Management Systems (RDMS). It’s an integral part of the LAMP stack and is a popular database management system in web hosting, data analytics,

Ubuntu has long stood as a bastion of accessibility, polish, and power in the Linux ecosystem. With the arrival of Ubuntu 25.04, codenamed “Plucky Puffin”, Canonical has once again demonstrated its commitment to delivering a

MongoDB is a high-performance, highly scalable document-oriented NoSQL database built to manage heavy traffic and vast amounts of data. Unlike traditional SQL databases that store data in rows and columns within tables, MongoDB structures data in a J
