{"id":1474,"date":"2022-07-06T11:46:10","date_gmt":"2022-07-06T11:46:10","guid":{"rendered":"https:\/\/linuxstans.com\/?p=1474"},"modified":"2022-07-06T11:46:38","modified_gmt":"2022-07-06T11:46:38","slug":"shutdown-linux","status":"publish","type":"post","link":"https:\/\/linuxstans.com\/shutdown-linux\/","title":{"rendered":"Shutdown Linux Using The Command Line"},"content":{"rendered":"<p>In this tutorial, we&#8217;re going to show you how to shut down your Linux computer using the command-line interface (CLI), aka Terminal.<\/p>\n<p><!--more--><\/p>\n<p>The shutdown command is especially useful for <a href=\"https:\/\/linuxstans.com\/best-linux-distros-servers\/\">Linux servers<\/a>. It&#8217;s also useful if you&#8217;re writing a bash script or if you just prefer using the CLI instead of the GUI on your Linux distro.<\/p>\n<p>This tutorial will work on any Linux distro, including <a href=\"https:\/\/linuxstans.com\/how-to-install-ubuntu-20-04-video-screenshots\/\">Ubuntu<\/a>, Linux Mint, CentOS, Fedora, <a href=\"https:\/\/linuxstans.com\/things-most-people-do-after-installing-debian\/\">Debian<\/a>, etc.<\/p>\n<p>So, open up the Terminal, or SSH into your server, and follow the instructions below.<\/p>\n<p><strong>You need to use the root user or use sudo with each command.<\/strong><\/p>\n<h2>How to use the shutdown command on Linux<\/h2>\n<p>The basic syntax of the shutdown command is:<\/p>\n<pre>shutdown [OPTIONS...] [TIME] [MESSAGE...]<\/pre>\n<p>The [TIME] is used to delay the shutdown command (shutdown the system after a certain amount of time). It can be specified in the hh:mm format. You can use one digit for the hours too. You can also just use &#8220;+m&#8221; if you want to wait only a certain amount of minutes.<\/p>\n<p>The [MESSAGE] is a message all other logged-in users see. It&#8217;s often used to let others know that the system will shut down and that they should save all their work.<\/p>\n<p>Here are some of the useful [OPTIONS] you can use with the command:<\/p>\n<ul>\n<li>&#8211;<strong>H<\/strong> &#8211; Halt the machine<\/li>\n<li>&#8211;<strong>P<\/strong> &#8211; Power off the machine<\/li>\n<li><strong>-r<\/strong> &#8211; Reboot the machine<\/li>\n<li>&#8211;<strong>h<\/strong> &#8211; Equivalent to -P, overridden by -H<\/li>\n<li><strong>-k<\/strong> &#8211; Don&#8217;t halt\/power off\/reboot, just send warnings<\/li>\n<li><strong>-c<\/strong> &#8211; Cancel a pending shutdown<\/li>\n<\/ul>\n<p><strong>The most basic and often used example of the command is:<\/strong><\/p>\n<pre>sudo shutdown -h now<\/pre>\n<p>This command will shut down the Linux system immediately.<\/p>\n<h2>5 Examples of the shutdown command on Linux<\/h2>\n<p>Here are some useful examples and use cases of the shutdown command:<\/p>\n<h3>Reboot your system<\/h3>\n<p>To reboot your system using the shutdown command, you just need to use the -r option:<\/p>\n<pre>shutdown -r now<\/pre>\n<p>Although a much easier way to reboot a Linux system is to just use the reboot command:<\/p>\n<pre>reboot<\/pre>\n<h3>Schedule a shutdown at 4:15 pm with a message<\/h3>\n<p>To schedule a shutdown after work hours are over, at 4:15 pm (16:15), run the following command:<\/p>\n<pre>shutdown -h 16:15 \"The server will shut down at 4:15pm, please save everything before leaving work.\"<\/pre>\n<h3>Schedule a shutdown after 10 minutes<\/h3>\n<p>If you want to schedule a shutdown 10 minutes after running the command (giving you enough time to save everything), run the following command:<\/p>\n<pre>shutdown -h +10<\/pre>\n<h3>Reboot the system after 5 minutes with a message<\/h3>\n<p>To reboot the system in 5 minutes and broadcast a message to all users, run:<\/p>\n<p>shutdown -r +5 &#8220;The server will reboot in 5 minutes due to kernel upgrades. Please save your work.&#8221;<\/p>\n<h3>Cancel a scheduled shutdown<\/h3>\n<p>If you scheduled a shutdown command by mistake, you can cancel it with the -c option:<\/p>\n<pre>shutdown -c<\/pre>\n<p>You can combine all these examples\/options and create a shutdown command of your own.<\/p>\n<p>Now that you learned what the shutdown command can do, you can clearly see its usefulness.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we&#8217;re going to show you how to shut down your Linux computer using the command-line interface (CLI), aka Terminal.<\/p>\n","protected":false},"author":1,"featured_media":1495,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[133,180],"class_list":{"0":"post-1474","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"tag-commands","9":"tag-shutdown","10":"czr-hentry"},"jetpack_featured_media_url":"https:\/\/linuxstans.com\/wp-content\/uploads\/2022\/07\/shutdown-linux.jpg","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/posts\/1474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/comments?post=1474"}],"version-history":[{"count":3,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/posts\/1474\/revisions"}],"predecessor-version":[{"id":1496,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/posts\/1474\/revisions\/1496"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/media\/1495"}],"wp:attachment":[{"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/media?parent=1474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/categories?post=1474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxstans.com\/wp-json\/wp\/v2\/tags?post=1474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}