<p>In this guide, I am going to show you how to shutdown and reboot your system using the Linux command line.</p><p>Most people use graphical desktop environments nowadays and therefore they shut down using the relevant menu option.</p><p>If you have a single board computer such as <a href="https://www.lifewire.com/raspberry-pi-projects-for-beginners-2495309" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="1">the Raspberry PI</a> or you are running a headless computer (one without a display) then you might want to know how to shut the computer down and restart it without physically pulling the power.</p><h3>How To Shutdown Your Computer Using The Linux Terminal</h3><p>The command required to shut down your machine is as follows:</p><blockquote><p>shutdown</p></blockquote><p>It is highly likely that you need to have elevated privileges to use the shutdown command so you are more likely to use <a href="https://www.lifewire.com/what-to-know-sudo-command-3576779" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="2">the sudo command</a> as follows:</p><blockquote><p>sudo shutdown</p></blockquote><p>The output from the above command will say something along the lines of &#34;shutdown scheduled for , use shutdown -c to cancel&#34;.</p><p>Generally, it is better to specify when you want the computer to shutdown. If you want the computer to shutdown immediately use the following command:</p><blockquote><p>sudo shutdown now</p></blockquote><p>The time element can be specified in a number of ways. For example, you could use the following command to also shut down the computer immediately:</p><blockquote><p>sudo shutdown 0</p></blockquote><p>The number refers to the number of minutes to wait before the system attempts to shut down.</p><p>Incidentally, the command <strong>sudo shutdown </strong>without any time element is the equivalent of running the following command:</p><blockquote><p>sudo shutdown 1</p></blockquote><p>The default, therefore, is 1 minute.</p><p>You can also specify a set time in hours and minutes to shut down your computer as follows:</p><blockquote><p>sudo shutdown 22:00</p></blockquote><p>When the amount of time until shut down is less than 5 minutes the system will not allow any more users to login.</p><p>If you are running a system with multiple users you can specify a message which will appear on all users screens letting them know that a shutdown is going to occur.</p><blockquote><p>sudo shutdown 5 &#34;save your work, system going down&#34;</p></blockquote><p>For completeness there is another switch you can use which is as follows:</p><blockquote><p>sudo shutdown -P now</p></blockquote><p>Technically you don&#39;t need to use the -p as it actually stands for power off and the default action for the shutdown is to power off. If you want to guarantee that the machine powers off and doesn&#39;t just halt then use the -P switch.</p><p>If you are better at remembering words over switches you might prefer to use the following:</p><blockquote><p>sudo shutdown --poweroff now</p></blockquote><h3>How To Reboot Your Computer Using The Linux Command Line</h3><p>The command for rebooting your computer is also shut down. There is actually a reboot command as well which is used for legacy purposes and logically speaking is a more obvious command to use to reboot your computer but most people actually use the following command to reboot their computer:</p><blockquote><p>sudo shutdown -r</p></blockquote><p>The same rules apply to the reboot command as they do for the shutdown command.</p><p>What this means is that by default the <strong>shutdown -r </strong>command on its own will reboot the computer after 1 minute.</p><p>To reboot immediately you have to specify either of the following commands:</p><blockquote><p>sudo shutdown -r 0</p><p>sudo shutdown -r now</p></blockquote><p>If you want the computer to reboot in 5 minutes you can specify the following command:</p><blockquote><p>sudo shutdown -r 5</p></blockquote><p>You can also specify a time to reboot the computer in hours and minutes as follows:</p><blockquote><p>sudo shutdown -r 22:00</p></blockquote><p>Finally, as with the shutdown procedure, you can specify a message to be displayed to all users of the system letting them know the system is going down.</p><blockquote><p>sudo shutdown -r 22:00 &#34;the system is going to bounce. Boing!!!&#34;</p></blockquote><p>If you prefer to you can use the following instead of the -r switch:</p><blockquote><p>sudo shutdown --reboot now</p></blockquote><h3>Make The System Halt</h3><p>You can specify one more command which shuts down the operating system but doesn&#39;t actually power off the machine.</p><p>The command is as follows:</p><blockquote><p>sudo shutdown -H</p></blockquote><p>You can also use the following command:</p><blockquote><p>sudo shutdown --halt</p></blockquote><h3>How To Cancel A Shutdown</h3><p>If you have scheduled a shutdown for the future then you can actually cancel the shutdown using the following command:</p><blockquote><p>shutdown -c</p></blockquote><p>If you have used either <strong>shut down now</strong> or <strong>shutdown 0</strong> then this won&#39;t have time to work.</p><h3>How To Create A Keyboard Shortcut To Shutdown Ubuntu</h3><p>If you are using Ubuntu you can easily create keyboard shortcuts to shutdown and reboot your computer.</p><p>Press the super key (key with the Windows symbol on it) on your keyboard and type the word &#34;keyboard&#34;.</p><p>When the keyboard icon appears click on it.</p><p>The keyboard application will load as shown in the attached image. There are two tabs:</p><ul><li>Typing</li><li>Shortcuts</li></ul><p>Click on the &#34;Shortcuts&#34; tab and click the plus symbol at the bottom of the screen to add a new shortcut.</p><p>Enter &#34;Shutdown Computer&#34; as the name and type the following as the command:</p><blockquote><p>gnome-session-quit --power-off --force</p></blockquote><p>Click &#34;Apply&#34;.</p><p>To assign the shortcut click on the word &#34;disabled&#34; next to &#34;Shutdown Computer&#34; and hold down the keys you wish to use. (For example CTRL and PgDn).</p><p>To add a keyboard shortcut to reboot your computer press the button with the plus symbol again and this time enter &#34;Reboot Computer&#34; as the name and the following as the command:</p><blockquote><p>gnome-session-quit --reboot --force</p></blockquote><p>Click &#34;Apply&#34;.</p><p>To assign the shortcut click on the word &#34;disabled&#34; next to the words &#34;Reboot Computer&#34; and press the keys you wish to use as the shortcut. (For example CTRL and PgUp).</p><p>What you will notice is that when you press the keyboard shortcut a little window will pop up asking what you want to do anyway so you can get away with one keyboard shortcut for both commands.</p><p>It is worth pointing out that you can already use a keyboard shortcut for logging out which as you might have guessed is CTRL, ALT and Delete, the same as Windows.</p><h3>Summary</h3><p>For completeness you might want to check out the manual pages for these legacy commands:</p><ul><li><a href="http://man7.org/linux/man-pages/man8/halt.8.html" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="3" rel="nofollow">halt</a></li><li><a href="http://linux.die.net/man/8/poweroff" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="4" rel="nofollow">power off</a></li><li><a href="http://man7.org/linux/man-pages/man2/reboot.2.html" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="5" rel="nofollow">reboot</a></li></ul>