Novice technical circle, understand your technical circle, send
B02
orb02
to receive a large number of Linux learning materials Gift pack!
In Linux, restarting a system or server is a common operation. To restart the system safely, you can use commands such as reboot
or shutdown
. Here are how to use several commands:
1. Use reboot
Instruction
reboot
The command is used torestart the system immediately. To reboot your system, just execute the following command:
sudo reboot
sudo
: Run the command with administrator privileges because the restart operation requires special privileges.reboot
: Indicates to perform restart operation immediately.
The system will send a restart signal and then restart.
2. Use shutdown
Instruction
shutdown
The command allows you to shut down or restart the system at a scheduled time and send a notification to all users. To restart the system immediately, you can execute the following command:
sudo shutdown -r now
sudo
: Run the command with administrator privileges because the restart operation requires special privileges.-r
: means restart.now
: Indicates to perform restart operation immediately.
If another user logs into the system, the shutdown
command will send a notification message and perform a restart after a period of time.
3. Delay before shutdown
If you want a delay before restarting to allow other users to save their work and log out, use the parameter with the shutdown
command. -t
For example, to restart the system after 5 minutes, you can execute the following command:
sudo shutdown -r +5
This will send a reboot notification to all users and perform the reboot after 5 minutes.
4. Restart using the init command
There is another command that can also be used to restart your Linux system, that is the init
command. In Linux systems, init
is the first process called by the kernel, and its PID (process ID) is always 1. If you want to use this command to reboot, you can do this:
init 6
In this command, the number 6 is a runlevel and represents a reboot.
at last
Whether using the reboot
or shutdown
commands, administrator privileges are required to perform the restart operation. Please make sure you have sufficient permissions to avoid unexpected reboots or shutdowns.