Sunday, August 28, 2016

Shutting Down System

You can use several commands to properly shut down a Linux system, including the following: 

init 0: Switches the system to runlevel 0, which halts the system 
init 6: Switches the system to runlevel 6, which reboots the system 
halt:  Shuts down the system  
reboot:  Reboots the system 

In addition to these commands, you can also use the shutdown command to either shut down or reboot the system. It has several key advantages over the preceding commands: 
You can specify that the system go down after a specified period of time. This gives your users time to save their work and log out before the system goes down. It also allows you to shut down the system at a specified time even if you’re not there to do it.
It allows you to send a message to all logged-in users warning them that a shutdown is pending.
It does not allow other users to log in before the pending shutdown.
The syntax for using shutdown is shutdown +m –h|–r message. The +m option specifies the amount of time (in minutes) before shutting down the system. You can also use the now option instead of +m to specify that the system go down immediately. If you need the system to go down at a specific time, you can replace +m with the time (entered as hh:mm) when the shutdown should occur. The –h option specifies that the system be halted, whereas the –r option specifies that the system be rebooted. Some examples of using shutdown are shown here:
shutdown +10 –h Please save your work and log out.

When you enter this command, all other logged-in users see the following message:
tux@ws1:~/Desktop>
Broadcast message from root@ws1 (pts/3) (Thu Feb 17 10:29:59 2011):

Please save your work and log out.
The system is going DOWN for system halt in 10 minutes!

If you’ve scheduled a shutdown using the shutdown command and later need to cancel that shutdown, enter shutdown –c at the shell prompt.
You can also use the wall command to send messages to users to inform them of system events, such as a system reboot or a runlevel change. To use wall, you must send the message to the stdin of the wall command. An example is shown here: 
openSUSE:~ # echo "The system is going down for a reboot." | wall
Broadcast Message from rtracy@openSUSE
        (/dev/pts/1) at 16:26 ...

The system is going down for a reboot.

No comments:

Post a Comment