Different ways to shut down a system
I was asked this question in an interview for QA position:
Tell me all the possible ways you can shutdown your system. The system could be in a network.
I know this question is little vague. This was question asked by the interviewer, may be he was expecting me to answer with respect to virtualization?
My Answer: use ssh to shutdown different systems in the network.
He was satisfied with this answer, but was expecting me to tell me some other ways.
So, what are other ways of shutting down a system?
What kind of system? Do you have physical access? Does "shutdown" mean clean shutdown? Do you want to power the system down simultaneously?
Here is the list I have so far:
Any OS:
- Push the power button (may need to hold down for ~5 seconds) (*may not be clean)
- Unplug the power cord from the system (will not be clean)
- Cut the power cord (will not be clean)
- Unplug the power cord from the UPS, powerstrip, or wall that it is connected to (will not be clean)
- Remove critical components from the system (disks, power supply, CPU, RAM) (definitely not clean)
- Destroy system with insert your preferred method destruction here (clean doesn't matter, cause you can't recover from this type of shutdown without a time machine)
Windows:
- Start -> Shutdown
- At command prompt, type
shutdown /p /f
(you can doshutdown /?
for a list of flags, there are lots of choices) - Over the network:
shutdown \\machinename /y /c
(from Mark Henderson's answer)
Linux:
- Choose the shutdown command in your GUI (too dependent on GUI to give specifics here)
-
shutdown -h now
(-h will power it off) init 0
-
halt
(Ah, this brings back memories of the good old days:sync;sync;halt
) -
ssh root@machinename shutdown -h now
(if you can't ssh as root, then dosudo shutdown ...
)
FreeBSD:
-
shutdown -p now
(-p will power it off) - Choose the shutdown command in your GUI (too dependent on GUI to give specifics here)
halt
OSX:
- Click the Apple in the task bar ->
Shut Down
- From Terminal.app ->
shutdown -h now
VMware:
- Choose appropriate command from above list depending on the guest OS.
- Right Click guest, choose
Power -> Power Off
(or click on it and do CTRL+E) - Right Click guest, choose
Power -> Shut Down Guest
(or click on it and do CTRL+D) -
vmrun -T server -h https://IP-OF-HOST:8333/sdk -u user -p password stop "[datastore] guest.vmx"
(this assumes you have vmrun access from a command line) - Kill virtualization process on the host (not clean)
Xen:
- Choose appropriate command from above list depending on the guest OS
xm shutdown machinename
- Kill virtualization process on the host (not clean)
Virtual Box:
- Choose appropriate command from above list depending on the guest OS
- Close the Host's window, where you will get an option to Power Off the virtual machine(s)
- Kill virtualization process on the host (not clean)
I'm sure there are MANY others, I will add them to my answer as they come to me (or people post them in the comments).
- Windows:
shutdown \\machinename /y /c
- Xen:
xm shutdown machinename
orxm destroy machinename
- VMWare: Log into vSphere management console, right-click machine and choose "shut down"
If the machine has a network-controlled power strip you could log into the power strip and turn the power off.
halt
init 0
shutdown -h now
are three you can run on the shell
I use a LogMeIn to control servers remotely. We've got a small infrastructure and it does the job quite well (and is secure).
If you want to "set it and forget it" then you can use a small program called "Switch Off" which also does well for remote reboots late at night.