{"id":15823,"date":"2019-03-05T09:51:23","date_gmt":"2019-03-05T09:51:23","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15823"},"modified":"2024-11-18T13:47:06","modified_gmt":"2024-11-18T13:47:06","slug":"how-to-use-the-linux-shutdown-command-in-ubuntu-18-04-and-centos-7","status":"publish","type":"post","link":"\/ph\/tutorials\/linux-shutdown-command\/","title":{"rendered":"How to Use the Linux Shutdown Command in Ubuntu and CentOS"},"content":{"rendered":"<p>Most of the popular Operating systems out there allow you to shut down your PC or laptop with different methods. Linux operating systems also has ways for a user to safely shutdown, reboot, hibernate or suspend your Unix based machine. In this tutorial, we&rsquo;ll show you how to use the shutdown safely, reboot, hibernate your VPS using Linux commands.<\/p><p>We&rsquo;ll walk you through the process using two different Linux distributions: CentOS and Ubuntu 22.04.<\/p><p>Every operating system requires a shutdown or reboot to keep things running as they should. Shutting down a server via the command line is a secure method because it notifies all logged in users that the system is about to be turned off.<\/p><p>Here, you&rsquo;ll even learn how to trigger the OS to power off on a schedule using Linux commands.<\/p><p><strong>A Brief Overview of the Linux Shutdown Command:<\/strong><\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td>Required Knowledge<\/td><td>Basic Linux commands, Terminal usage<\/td><\/tr><tr><td>Privileges Required<\/td><td>Root<\/td><\/tr><tr><td>Difficulty<\/td><td>Beginner<\/td><\/tr><tr><td>Main Goal<\/td><td>Shutdown, Reboot, and System Power Management<\/td><\/tr><tr><td>OS Compatibility<\/td><td>Linux Distributions, Unix-like Systems<\/td><\/tr><\/tbody><\/table><\/figure><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet.png 2048w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/Linux-cheat-sheet-768x212.png 768w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure>\n<\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-the-shutdown-command\">What Is the Shutdown Command <\/h2><p>The shutdown command in Ubuntu and CentOS lets you power off, reboot, and halt your system. Below is the command syntax that is used to shutdown and restart the machine.<\/p><pre class=\"wp-block-preformatted\">Shutdown [OPTIONS] [TIME] [WALL]<\/pre><p>The shutdown command can also reboot, halt, or power off your system.<\/p><p>The first argument of <strong>[OPTIONS]<\/strong> can be a time string. After the argument, optionally you can type in a wall message to notify the logged-in users before shutting down your system.<\/p><p>The format for the time string is <strong>hh:mm<\/strong> (hour\/minute) &ndash; a 24-hour time format. This will specify the time to execute the shutdown command. Alternatively, you can use <strong>+m<\/strong> where <strong>m<\/strong> indicates minutes. It will instruct the machine to shutdown in the number of minutes you want.<\/p><p>You can also use <strong>now<\/strong> in the syntax which is an alias for <strong>+0<\/strong>, this will trigger an immediate shutdown of your VPS. If you don&rsquo;t specify the <strong>[time]<\/strong> argument, Linux as default implies<strong> +1<\/strong> before shutting down.<\/p><p>Bear in mind that a time argument is a must if you want to specify a wall message. The <strong>\/run\/nologin<\/strong> file will be created 5 minutes before the system shuts down only if you have implied a time argument to ensure that further logins are not to be allowed.<\/p><h2 class=\"wp-block-heading\" id=\"h-shutdown-command-examples-in-linux-and-centos\">Shutdown Command Examples in Linux and CentOS<\/h2><p>Now let&rsquo;s go over some basic shutdown command usage in Linux and CentOS.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-use-the-shutdown-command-in-linux-ubuntu-and-centos\">How to Use the Shutdown Command in Linux Ubuntu and CentOS<\/h3><p>The shutdown command for Ubuntu and CentOS is relatively similar. Each command shown below can be used in its dedicated Terminal. Remember, that you&rsquo;ll have to use SSH to access your VPS. We have a <a href=\"\/ph\/tutorials\/how-to-use-putty-ssh\/\">tutorial<\/a> covering the process with PuTTY!<\/p><p>The basic shutdown command for both CentOS and Ubuntu looks like this:<\/p><pre class=\"wp-block-preformatted\">shutdown<\/pre><p>The command above will not shut down your PC immediately; it will set a one-minute timer before shutting down. Remember to save your work before the shutdown takes place.<\/p><p>To shut down your PC immediately, type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">shutdown now<\/pre><p>As we mentioned before, here, the command for both OS is the same.<\/p><p>To shut down your PC at a dedicated time, type in the following command into the command line and hit enter:<\/p><pre class=\"wp-block-preformatted\">shutdown hh:mm<\/pre><p>The Linux shutdown command follows a 24 hours format so type in hours instead of <strong>hh<\/strong> and minutes instead of <strong>mm<\/strong>.<\/p><p>To shut down after a few minutes or hours, type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">shutdown +m<\/pre><p>Remember, here m indicates minutes. Just specify the number of minutes.<\/p><p>To show a message to the people who are logged in your VPS type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">Shutdown +m &ldquo;Please save your Work, the PC will Shutdown in 5 Minutes&rdquo;<\/pre><p>Here the text in quotes can be whatever message you&rsquo;d like.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-restart-your-vps-using-the-shutdown-command-in-linux\">How to Restart Your VPS using the Shutdown Command in Linux<\/h3><p>To restart or reboot your PC safely, use the following command below:<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;r<\/pre><p>The command won&rsquo;t reboot your machine immediately, it will set a one-minute timer before rebooting. For this, you can save your work before reboot takes place.<\/p><p>To restart your PC immediately, just add the now option, as you did previously.<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;r now<\/pre><p>To schedule a restart for your system, type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;r hh:mm<\/pre><p>To restart after few minutes or hours, type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;r +m<\/pre><p>Remember, here <strong>m<\/strong> indicates minutes. Just specify the number of minutes.<\/p><p>To show the message to the people who are logged in with your server before the it goes down, type in the following command and hit enter:<\/p><pre class=\"wp-block-preformatted\">Shutdown &ndash;r +m &ldquo;Please save your Work, the PC will restart in 5 Minutes&rdquo;<\/pre><p>Here are some additional Linux shutdown command options you should be familiar with:<\/p><ul class=\"wp-block-list\">\n<li>-poweroff, -P : like halt Powers off the system (also turns off unit)<\/li>\n\n\n\n<li>-reboot, -r : Reboot the system.<\/li>\n\n\n\n<li>-halt, -h : Halt the machine after terminating processes.<\/li>\n<\/ul><p>You can also shut down the using the halt and power off options using the following command<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;h<\/pre><p>For powering off use:<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;p<\/pre><p>In the above commands, you can also specify the time and then wall message after the option argument.<\/p><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-how-to-cancel-a-scheduled-shutdown-command-in-linux\">How to Cancel a Scheduled Shutdown Command in Linux<\/h3><p>To cancel a Scheduled shutdown or a restart of your PC, you can simply type in the following command before you reach the dedicated time of the scheduled shutdown of your PC.<\/p><pre class=\"wp-block-preformatted\">shutdown &ndash;c<\/pre><p>These commands will immediately cancel the specified scheduled time of shutdown or restart. You cannot use this command If you used <strong>+0<\/strong> or <strong>now<\/strong>.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>That&rsquo;s it, hope this article helped you learn how to use the Linux shutdown command and its options. If you faced any confusion in the tutorial, please let us know so we can resolve it for you!<\/p><p>\n\n\n        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Discover Other Linux Commands for Server Management                <\/p>\n            <\/div>\n            <p class=\"protip__content\"><a href=\"\/ph\/tutorials\/vps\/how-to-check-and-manage-disk-space-via-terminal\/\">How to Check Disk Space on Linux<\/a><br>\n<a href=\"\/ph\/tutorials\/curl-command-with-examples-linux\/\">How to Transfer Data With Curl Command<\/a><br>\n<a href=\"\/ph\/tutorials\/linux-time-command\/\">How to Calculate Process Execution With Time Command<\/a><br>\n<a href=\"\/ph\/tutorials\/using-scp-command-to-transfer-files\/\">How to Transfer Files Using Scp Command<\/a><br>\n<a href=\"\/ph\/tutorials\/linux-watch-command\/\">How to Monitor Changes With Watch Command<\/a><br>\n<a href=\"\/ph\/tutorials\/how-to-use-rsync\/\">How to Transfer and Synchronize Data With Rsync<\/a><br>\n<a href=\"\/ph\/tutorials\/manage-and-list-services-in-linux\/\">How to Manage and List Services in Linux<\/a><br>\n<a href=\"\/ph\/tutorials\/how-to-kill-a-process-in-linux\/\">How to Kill a Process in Linux<\/a><\/p>\n                    <\/div>\n        \n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the popular Operating systems out there allow you to shut down your PC or laptop with different methods. Linux operating systems also has ways for a user to safely shutdown, reboot, hibernate or suspend your Unix based machine. In this tutorial, we&rsquo;ll show you how to use the shutdown safely, reboot, hibernate your [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/linux-shutdown-command\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Using the Linux Shutdown Command \u2013 a Step-by-Step Guide + Examples","rank_math_description":"Rebooting and powering down your system is essential for its health. Here's how you can do it with the Linux shutdown command.","rank_math_focus_keyword":"linux shutdown command","footnotes":""},"categories":[],"tags":[],"class_list":["post-15823","post","type-post","status-publish","format-standard","hentry"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/linux-shutdown-command\/","default":1},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/comando-shutdown-linux\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/commande-shutdown-de-linux\/","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/comando-shutdown-linux\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/perintah-shutdown-linux\/","default":0},{"locale":"nl-NL","link":"https:\/\/www.hostinger.com\/nl\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-use-the-linux-shutdown-command-in-ubuntu-18-04-and-centos-7\/","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-use-the-linux-shutdown-command-in-ubuntu-18-04-and-centos-7\/","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/linux-shutdown-command\/","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/comando-shutdown-linux\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/comando-shutdown-linux\/","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/comando-shutdown-linux\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/comando-shutdown-linux\/","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/15823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=15823"}],"version-history":[{"count":30,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/15823\/revisions"}],"predecessor-version":[{"id":118966,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/15823\/revisions\/118966"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=15823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=15823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=15823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}