Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

shutdown, reboot, poweroff, halt

Stop, restart or switch off the system cleanly — now or at a planned time, with a warning to users.

Niveau
RHCSA-examen
Groep
Services en opstarten
Root nodig
Ja
Pakket
systemd
Ook
reboot, poweroff, halt

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

On RHEL these commands are part of systemd. They ask systemd to stop all services in the right order, write all data to disk and then reboot or power off.

halt stops the system but does not switch off the power; use poweroff to switch off.

Zo schrijf je het

shutdown [OPTIONS] [TIME] [MESSAGE]
shutdown -c
reboot [OPTIONS]
poweroff [OPTIONS]
halt [OPTIONS]

Opties 19

Meest gebruikt

shutdown

-r, --reboot
Reboot the system.
-h
Power off (the same as -P, unless --halt is also given).
-P, --poweroff
Power off the machine (the default).
-H, --halt
Halt: stop the system but do not switch off.
-c
Cancel a planned shutdown.
-k
Do not shut down; only send the warning message.
--no-wall
Do not send a message to the users.
--show
Show the planned shutdown, if there is one.
TIME
now, +M (in M minutes) or hh:mm (a clock time, 24 hours). Default: +1.
MESSAGE
The text that users see in their terminals.
--help
Show help.

reboot, poweroff, halt

-f, --force
Do not stop services first; twice (-ff) = immediately, like pulling the plug.
-p, --poweroff
With halt: power off.
--reboot
With halt or poweroff: reboot instead.
--halt
With reboot or poweroff: halt instead.
-w, --wtmp-only
Only write the wtmp record; do nothing else.
-d, --no-wtmp
Do not write the wtmp record.
-n, --no-sync
Do not sync the disks before.
--no-wall
Do not send a message.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Reboot now

    reboot

    The same as systemctl reboot.

  2. 2Power off now

    poweroff

    The same as systemctl poweroff or shutdown -h now.

  3. 3Reboot in 10 minutes with a message

    shutdown -r +10 "Kernel update. Please save your work."

    Logged-in users see the message now and again before the reboot.

  4. 4Power off at a clock time

    shutdown -h 23:30 "Hardware maintenance tonight"

    24-hour time of the server's time zone.

  5. 5Cancel a planned shutdown

    shutdown -c

    Users get a message that it was cancelled.

  6. 6Show the planned shutdown

    shutdown --show

    Check before you plan another one.

  7. 7Only warn users, do not shut down

    shutdown -k +5 "Test message: maintenance starts soon"

    Useful to test what users see.

  8. 8Reboot a remote server and wait until it is back

    ssh root@server2 reboot; sleep 60; until ssh -o ConnectTimeout=5 root@server2 true; do sleep 10; done; echo "server2 is back"

    A simple loop in a patch script.

  9. 9Reboot after an update only when the kernel changed

    dnf needs-restarting -r || systemctl reboot

    needs-restarting -r returns 1 when a reboot is needed.

  10. 10Force a reboot when services hang

    systemctl reboot --force

    Skips the clean stop of services. Use only when a normal reboot hangs.

  11. 11See past reboots

    last -x reboot shutdown | head

    When did the system reboot, and who shut it down?

Let op

  • halt does not power off. On real hardware the machine stays on with the screen showing "System halted".
  • reboot -ff is like pulling the plug: open files can be damaged.
  • On a remote server, a poweroff cannot be undone without someone at the machine (or a remote console).

Bestanden

/var/log/wtmp
Records of reboots and logins (read with last).
/run/nologin
Made by shutdown 5 minutes before the time: new logins are refused.

Tips om te onthouden

  • Now: reboot / poweroff. Later: shutdown -r +10. Undo: shutdown -c.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 shutdown