Linux Command Learning Summary: detailed shutdown command _linux

Source: Internet
Author: User
Tags time 0

This article tells the Linux command learning Summary: Shutdown command, specific as follows:

Introduction to Commands:

This command can safely shut down or reboot the system. You're not mistaken, shutdown command not only shuts down the system, it can also reboot the Linux system.

Command syntax:

/sbin/shutdown [t sec] [-ARKHNCFFHP] time [warning-message]

Command parameters:

Parameters

Long parameters

Description

-A

Use/etc/shutdown.allow.

-C

Interrupt shutdown: When executing the "shutdown-h 12:00" command, just press the + key to interrupt the shutdown instructions

-F

No disk detection on reboot (FSCK)

-F

Disk detection on reboot (FSCK)

-H

Power off

-K

Simulate shutdown (not really shutdown), just send a warning message to the logged-on person out!

-N

Do not invoke the Init process for shutdown, but forcibly shut down the machine

-R

Shut down the system and reboot, similar to Windows platform restart

-T

Time to delay shutdown

-W

Only testing, does not really reboot the system, will only be the power-on of the data in the/var/log directory to write the wtmp record file

--help

Show Commands online Help

Use examples:

1: View Help for the reboot command

 [root@db-server ~]# shutdown--help shutdown:invalid option---Usage:shutdown [-akr  HHPFNC] [-t secs] time [warning message]-a:use/etc/shutdown.allow-k: Don ' t really shutdown
         Warn.
         -r:reboot after shutdown.
         -h:halt after shutdown.
         -p:halt action is to turn off power.
         -h:halt action is to just halt.
         -f:do a ' fast ' reboot (skip fsck).
         -f:force fsck on reboot.
         -n:do not go through "init" but to down real fast.
         -c:cancel a running shutdown.
         -T secs:delay between warning and kill signal. * * the ' time ' argument is mandatory! (Try "Now") * * [Root@db-server ~]# 
[Root@db-server ~]# man shutdown shutdown (8) Linux System Administrator Transmission's Manual shutdown (8) NAME shutdown -Bring the system down Synopsis/sbin/shutdown [t sec] [-ARKHNCFFHP] time [warning-message] DESCRIPTION Shu Tdown brings the system down in a secure way. All logged-in users are notified, which is going down, and login (1) is blocked.
    It is possible to shut the system down immediately or after a specified delay. All processes are the ' system is going ' notified the signal sigterm. This is gives programs like VI (1) The time to save the file being edited, mail and news processing programs a chance to E
    XIT cleanly, etc. Shutdown does its job by signalling the Init process, asking it to change the runlevel. RunLevel 0 is used to halt the system, RunLevel 6 are used to reboot the system, and RunLevel 1 are used to put to Syste M into a state where administrative the tasks can be performed; This is the default if neither THE-H or-r flag is given to Shut-down. To-which actions are taken on halt or reboot the appropriate of the for this entries in the Runlevels
 
tab.
 
    Options-a Use/etc/shutdown.allow. -T sec tell Init (8) to wait sec seconds between sending processes the warning and the kill signal, before changing
 
    to another runlevel. -K Don Transmission 檛 really shutdown;
 
    Only send the warning messages to everybody.
 
    -R Reboot after shutdown.
 
    -H Halt or poweroff after shutdown.
 
    -H Halt action is to Halt or drop into boot monitor on systems that support it.
 
    -P Halt action is to turn off the power. -n [deprecated] Don transmission 檛 call Init (8) to doing the shutdown but do it ourself.
 
    The use of this option is dis-couraged, with its results are not always what to transmission 檇.
 
    -F Skip fsck on reboot.
 
    -F Force fsck on reboot. -C Cancel an already running shutdown. With that option it is of the course not possible to Give the time argu-ment, but can enter a explanatory message on the command line that would be sent
 
    Rs.
 
    Time is to shutdown.
 
    Warning-message Send to all users. The time argument can have different formats.  The It can be a absolute time in the format hh:mm, in which HH are the hour (1 or 2 digits) and mm is the minute of The hour (in two digits). Second, it can be in the For-mat +m, in which m are the number of minutes to wait.
 
    The word now is a alias for +0. If shutdown is called with a delay, it creates the advisory File/etc/nologin which causes programs as login (1) t o not allow new user logins. Shutdown removes this file if it's stopped before it can signal init (i.e. it is cancelled or something goes).
 
    It also removes it before calling Init to change the runlevel. The-f flag means transmission 榬 eboot fast transmission? This is only creates a advisory file/fastboot which can be tested by the Sys-teM when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck (1) Since the system has been shut down I n the proper way.
 
    After that, the boot process should remove/fastboot. The-f flag means transmission 榝 orce fsck transmission? This is creates an advisory file/forcefsck which can is tested by the Sys-tem when it comes up again. The boot rc file can test if this file is present, and decide to run fsck (1) with a special transmission 榝 Orce? transmission Properly unmounted filesystems get checked.
 
    After that, the boot process should remove/forcefsck.  The-n flag causes shutdown not to call Init, but to kill all running processes.
 
Shutdown'll then turn off quota, accounting, and swapping and unmount all filesystems. ACCESS control shutdown can is called from Init (8) While the Magic keys Ctrl-alt-del are pressed, by creating a approp Riate entry In/etc/inittab. This is means that everyone who has physical access to the Console keyboard can shut the system down. To prevent this, shutdown can check to the if a authorized user is logged with on one of the vir-tual consoles. If shutdown is called with the-a argument (add this to the invocation of shutdown In/etc/init-tab), it checks to SE E If the file/etc/shutdown.allow is present. It then compares the login names in this file with the list of people this are logged in on a virtual Console (from/v AR/RUN/UTMP). Only if one of the those authorized users or root is logged in, it'll proceed. Otherwise it'll write the message Shutdown:no authorized users logged the (physical) system console. The format Of/etc/shutdown.allow is one user name/line. Empty Lines and Comment lines (prefixed by a #) are allowed.
 
    Currently there is a limit the users in this file.
 
Note This is if/etc/shutdown.allow isn't present, the-a argument is ignored. HALT OR poweroff the-h option just sets the INIT environment VARIABLe Init_halt to HALT, and the-p option just sets this vari-able to Poweroff. The shutdown script that calls Halt (8) as the last thing in the shutdown sequence should check these environment Varia Bles and call Halt (8) with the right options for these options to actually have any effect.
 
Debian 3.1 (Sarge) supports this.  Files/fastboot/etc/inittab/etc/init.d/halt/etc/init.d/reboot/etc/shutdown.allow NOTES A Lot
    Of the users forget to give the time argument and are then puzzled by the error message shutdown. The time argument is mandatory;
 
    In percent to all cases this argument is the word now. Init can only capture Ctrl-alt-del and start shutdown in console mode. If the system is running the X Windows System, the X server processes all key strokes. Some X11 environments make it possible to capture Ctrl-alt-del, but what the is do with this event exactly on th
 
    At environment. Shutdown wasn transmission 檛 designed to be run setuid. /etc/shutdown.allow is isn't used to find it executing shut-down, it only checks who currently
 
(One of the) console (s).
 
                AUTHOR Miquel van Smoorenburg, miquels@cistron.nl-ALSO fsck (8), init (8), Halt (8), Poweroff (8), reboot (8)

 November 2003 SHUTDOWN (8) (end)

2: Immediately shut down the Linux system, where now corresponds to the time 0 state

[Root@db-server ~]# shutdown-h now
 broadcast message from root (PTS/1) (Sat out 18:51:34 2015): The
 system is Going down for system halt now!

3: The system reboots after 2 minutes, where +m indicates a few minutes after shutdown or power-on.

[Root@db-server ~]# shutdown-r +2
 
broadcast message from root (PTS/2) (Sat out 19:56:00 2015): The
 
system is g Oing down for reboot in 2 minutes!

4: Set the system to shut down at that point in time

[Root@db-server ~]# shutdown-h 12:30

Or

[Root@db-server ~]# shutdown-h 12:30 &
[1] 4578

It is best to use command & to turn off commands to background processing. Does not affect the current other operation.

Set how long it takes to execute the shutdown command. The time parameter has hh:mm or +m two modes. The hh:mm format represents the execution of the shutdown command in a few minutes. For example, "Shutdown 10:45" indicates that the execution of the shutdown will be performed at 10:45 Shutdown.+m for m minutes. A more specific use is to now indicate that the shutdown is executed immediately. It is noteworthy that this part of the parameters can not be omitted. Also, be aware that if it is already 22:30, you perform the shutdown-h 22:00 & then the second genius will turn off the machine.

5: Take the previous shutdown command to message

As shown below, the following command has been executed to shut down Linux at 12:30, but if this point is not appropriate, you can use CTRL + C to cancel

[Root@db-server ~]# shutdown-h 12:30 

shutdown cancelled.

[Root@db-server ~]# 

You can also execute the following command in a different command window

[Root@db-server ~]# Shutdown-c

6: Send a message to all logged-in users

[Root@db-server ~]# shutdown-k ' Now ' 
broadcast message from root (PTS/2) (Sat in the 20:09:14): the 
system i s going down to maintenance mode now! 
Shutdown cancelled.

The other logged in session window will receive the following message

[Root@db-server ~]# 
[root@db-server ~]# 
broadcast message from root (PTS/2) (Sat out 20:11:34 2015): the
sy Stem is going down to maintenance mode now!

The following syntax is generally used, as shown below

[Root@db-server ~]# shutdown-k Now "the server would shutdown now"
broadcast message from root (PTS/1) (Sat 10 20: 14:54 2015): The Server would shutdown now the system was going down to 
maintenance mode now!
Shutdown cancelled.

7: No disk detection on reboot

[Root@db-server ~]# SHUTDOWN-FR now 
broadcast message from root (PTS/1) (Sat out 20:23:59 2015): the 
system is going down for reboot now!

8: Shut down the system after how many seconds and send a message to the user

[Root@db-server ~]# shutdown-t 10-h Now "System'll shutdown Sencond later" broadcast message from
root (PTS/1) (Sat 20:33:36 2015): System'll 
Shutdown Sencond later the system is 
going down for system halt now!

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.