| |
|
|
|
|
Linux tips and tweaksShut down Linux from the command lineHow do you shut down or restart Linux? Of course, you just click the option on the menu. It couldn't be simpler. Although this is indeed very straightforward, it is not always the best way to shut down the computer. One example is when the computer is accessed by other people on a network. Whether it is a work or home network, other people migh have files open or could be relying on your Linux PC for files and services. Shutting down immediately without warning could cause problems for them. Ideally, you should give people plenty of warning about the shutdown so that they can take the necessary actions, such as closing files or applications. Another situation where the shutdown menu item is not the best option is when you are downloading a big file. You might want to set it downloading at night or when you are out and then to automatically switch off the computer when it is done. Both these situations can be catered for if you use shutdown commands in a Terminal window. There are several commands to choose from, such as halt, reboot, poweroff and shutdown. Each of these has several command line switches that access various features or perform actions. It is useful to know these commands. Shutdown The shutdown command broadcasts the fact that the computer is shutting down over the network so that other people who are logged on can see that they will lose access to the PC and take the appropriate action. You can add a message, such as Tips: don't use ! in your messages because it has special meaning. You need to use sudo or su to elevate permissions. Press Ctrl+C if you change your mind and want to abort shutdown. If you're downloading a big file, use shutdown with sufficient time to for the download to complete.
The shutdown command doesn't actually turn off the computer's power and it just shuts down Linux. It puts it in a state where the power can be switched off. If you want to actually power-off the PC automatically then add the -h (halt) command switch like this There are more command line parameters and you can add -r to reboot the computer after shutting down Linux, add -F to run fsck (file system check) on startup, or -k to send everyone shutdown messages, but without actually shutting down - a cruel trick!
|