{"id":230,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:38","modified_gmt":"2020-08-22T20:26:38","slug":"this-is-the-page-title-toplevel-65","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=230","title":{"rendered":"Stopping the System"},"content":{"rendered":"\n<title>Stopping the System<\/title>\n<p>\nFor those of you who hadn&#8217;t noticed, Linux isn&#8217;t like <glossary>DOS<\/glossary>\nor Windows. Despite the superficial similarity at the\ncommand prompt and similarities in the <glossary>GUI<\/glossary>,\nthey have little in common. One very important difference is the way you stop the system.<\/p>\n<p>\nIn <glossary>DOS<\/glossary> or older versions of <glossary>Windows<\/glossary>\n(i.e prior to Windows Vista) you are\ncompletely omnipotent. You know everything that&#8217;s going on. You have complete\ncontrol over everything. If you decide that you&#8217;ve had enough and flip the power\nswitch, you are the only one doing so will effect. However, with dozens of\npeople working on an Linux system and dozens more using its resources, simply\nturning off the machine is not something you want to do. Despite the fact that\nyou will annoy quite a few people, it can cause damage to your system, depending\non exactly what was happening when you killed the power. (Okay, you could also\ncreate problems with a <glossary>DOS<\/glossary>\nsystem, but with only one person, the chances are less likely).\n<\/p>\n<p>\nOn a multi-user system like Linux, many different things are\ngoing on. You many not see any disk activity, but the system may still have\nthings in its buffers which are waiting for the chance to write to the hard disk. If you\nturn off the power before this data is written, what is on the hard disk may be\ninconsistent. <\/p>\n<question id=\"496\" text=\"Which file contains a list users, one of which must be logged in on a virtual console before the shutdown command can be used?\" \/>\n<concept id=\"208\" description=\"Like DOS and Windows, you can configure Linux so that Ctrl-Alt-Del will reboot your system (or not, if you choose).\" \/>\n<concept id=\"\" description=\"By default,  pressing Ctrl-Alt-Del will reboot your system.\" \/>\n<task name=\"\">Reboot the system Using Ctrl-ALt-Del<\/task>\n<p>\nNormally, pressing Ctrl-Alt-Del <i>will<\/i> reboot your system. You can prevent this by creating the file <file type=\"\">\/etc\/shutdown.allow<\/file>, which\ncontains a list (one entry per line) of users. If this file exists, the system\nwill first check whether one of the users listed in <file type=\"\">shutdown.allow<\/file> is logged in\non the system console. If none are, you see the message\n<\/p>\n<screenoutput>shutdown: no authorized users logged in.<\/screenoutput>\n<p>\nTo make sure that things are stopped safely, you need to shut down your system\n&#8220;properly.&#8221; What is considered &#8220;proper&#8221; can be a couple of things,\ndepending on the circumstances. Linux provides several tools to stop the system\nand allows you to decide what is proper for your particular circumstance.\nFlipping the power switch is <em>not<\/em> shutting down properly.\n<\/p>\n<concept id=\"\" description=\"Using Ctrl-Alt-Del to reboot is just a convention and any key combination could be used.\" \/>\n<question id=\"\" type=\"TF\" text=\"Using Ctrl-Alt-Del to reboot is just a convention and any key combination could be used.\" \/>\n<concept id=\"\" description=\"The key combination used to reboot your system is defined in \/etc\/defkeymap.map.\" \/>\n<question id=\"\" type=\"mc\" text=\"In which file is the key combination used to reboot your system defined?\" \/>\n<p>\nNote that the key combination Ctrl-Alt-Del is just a convention. There is nothing magic\nabout that key combination, other than people are used to it from DOS\/Windows. By default,\nthe combination Ctrl-Alt-Del is assigned to the special <glossary>keymap<\/glossary> &#8220;Boot&#8221;. This is typically defined by\ndefault in the file <file type=\"\">\/usr\/src\/linux\/drivers\/char\/defkeymap.map<\/file>, which is the keyboard mapping the\nkernel uses when it boots. However, you can use the <command>loadkeys<\/command> program to change this if\nyou need to.\n<\/p>\n<concept id=\"\" description=\"You could configure your system so that Ctrl-Alt-Del does nothing.\" \/>\n<p>\nIf necessary, you could define that the combination Ctrl-Alt-Del is not assigned to anything, therefore\nit would <strong>not<\/strong> shutdown your system. However, should the system get stuck in a state that you cannot correct, shutting it down with Ctrl-Alt-Del is often the only safe alternative (as compared with\nsimply flipping the power switch.)\n<\/p>\n<concept id=\"120\" description=\"The 'shutdown' command can send warnings at regular intervals as the system is shutting down.\" \/>\n<question id=\"500\" text=\"What option to shutdown forces the system to reboot?\" \/>\n<question id=\"115\" text=\"What command would you use if you wanted to send regular warnings to users as the system is shutting down?\" \/>\n<question id=\"426\" text=\"Unlike DOS and Windows, Ctrl-Alt-Del will not reboot your Linux system.\" \/>\n<p>\nWhen you press the &#8220;boot&#8221; key combination, the <command>init<\/command> program is sent the <glossary>signal<\/glossary> SIGINT. What <command>init<\/command> does will\ndepend on how the <file type=\"\">\/etc\/inittab<\/file> is configured. In the <tutorial id=65>section on run levels<\/tutorial>,\nwe talk about the various actions in <file type=\"\">\/etc\/inittab<\/file> that tell <command>init<\/command> what to do when the key combination Ctrl-Alt-Del is pressed (one being ctraltdel). On my system it is defined as\n<\/p>\n<commandexample command=\"shutdown\">\/sbin\/shutdown -r -t 4 now<\/commandexample>\n<p>\nwhich says to run the <command>shutdown<\/command> command immediately (now) and reboot (-r), waiting\nfour seconds between the time the warning message is sent and the shutdown procedure is started (-t 4).\n<\/p>\n<concept id=\"\" description=\"The shutdown command is the safest way to turn off your system as it gives users a warning.\" \/>\n<task name=\"Shutdown the system in 30 minutes\">Shutdown the system in 30 minutes and provide a message to anyone logged in using the shutdown command<\/task>\n<p>\nRunning <command>shutdown<\/command> is really the safest way of bringing your system down, although you\n<i>could<\/i> get away with running <glossary>init<\/glossary> 0. This would bring the system down, but\nwould not give the users any warning. The <command>shutdown<\/command> command can be configured to give the users enough time to stop what they are working on and save all of their data.\n<\/p>\n<p>\nUsing the <command>shutdown<\/command> command, you have the ability not only to warn your users that the system is going down but also to give them the chance to finish up what they\nwere doing.\n<\/p>\n<ol>\n<li>Login as root<\/li>\n<li>Issue the command\n<commandexample command=\"shutdown\">\nshutdown -h +30 &#8220;System going down for maintenance. Back up after lunch.&#8221;\n<\/commandexample>\n<p>\nThis message will appear on everyone&#8217;s screen immediately, then at increasing\nintervals, until the system finally goes down.\n<\/p>\n<\/li>\n<\/ol>\n<p>\nIf you have rebuilt your kernel or made other changes that require you to reboot your\nsystem, you can use shutdown as well, by using the -r option.\n<\/p>\n<concept id=\"\" description=\"The halt and reboot commands are typically the same binary.\" \/>\n<task name=\"\">Shutdown the system using the shutdown command<\/task>\n<p>\nThe first two tools to stop your system are actually two links in <directory>\/sbin<\/directory>: <command>halt<\/command> and\n<command>reboot<\/command>, that link to the same file. It&#8217;s likely that <command>\/sbin\/reboot<\/command>\nis a <glossary>symlink<\/glossary> to <command>\/sbin\/halt<\/command>\nIf either of these is called and the system is not in\n<glossary>run-level<\/glossary> 0 or 6, then <command>shutdown<\/command> (also in <directory>\/sbin<\/directory>) is called instead.\n<\/p>\n<question id=\"502\" text=\"What option to shutdown tells how many seconds to wait before starting the actual shutdown?\" \/>\n<question id=\"501\" text=\"What option to halt says to power off when the system is down?\" \/>\n<task name=\"\">Start a shutdown of the system in 15 minute and then cancel it<\/task>\n<p>\n<\/p>\n<task name=\"\">Reboot the system using the shutdown command<\/task>\n<task name=\"\">Shutdown the system using the halt command<\/task>\n<p>\n<table>\n  <tr>\n    <td>Option<\/td>\n    <td>Description<\/td>\n  <\/tr>\n  <tr>\n    <td>-d<\/td>\n    <td>Do not write to the <file type=\"\">\/var\/log\/wtmp<\/file>.<\/td>\n  <\/tr>\n  <tr>\n    <td>-f<\/td>\n    <td>Force a reboot, i.e. do not call shutdown.<\/td>\n  <\/tr>\n  <tr>\n    <td>-i<\/td>\n    <td>Shutdown the network interfaces before halting or rebooting.<\/td>\n  <\/tr>\n  <tr>\n    <td>-n<\/td>\n    <td>Do not sync (write data to disk) before halting or rebooting. <\/td>\n  <\/tr>\n  <tr>\n    <td>-p<\/td>\n    <td>Power off after shutdown.<\/td>\n  <\/tr>\n  <tr>\n    <td>-w<\/td>\n    <td>Do not actually stop the system, just write to \/var\/log\/wmtp.<\/td>\n  <\/tr>\n<\/table>\n<\/p>\n <p>\n<b>Table &#8211; Options to halt and reboot.<\/b>\n<p>\n<table>\n  <tr>\n    <td><b>Option<\/b><\/td>\n    <td><b>Description<\/b><\/td>\n  <\/tr>\n  <tr>\n    <td>-c<\/td>\n    <td>Cancel a shutdown that is in progress.<\/td>\n  <\/tr>\n  <tr>\n    <td>-f<\/td>\n    <td>Don&#8217;t run <command>fsck<\/command> when the system reboots (i.e. a &#8220;fast&#8221; reboot).<\/td>\n  <\/tr>\n  <tr>\n    <td>-F<\/td>\n    <td>Force <command>fsck<\/command> on reboot.<\/td>\n  <\/tr>\n  <tr>\n    <td>-h<\/td>\n    <td>Halt the system when the shutdown is completed. <\/td>\n  <\/tr>\n  <tr>\n    <td>-k<\/td>\n    <td>Send a warning message, but do not actually shutdown the system.<\/td>\n  <\/tr>\n  <tr>\n    <td>-n<\/td>\n    <td>Shutdown without calling init. DEPRECATED.<\/td>\n  <\/tr>\n  <tr>\n    <td>-r<\/td>\n    <td>Reboot the system after shutdown. <\/td>\n  <\/tr>\n  <tr>\n    <td>-t <i>seconds<\/i><\/td>\n    <td>Seconds to wait  before starting the shutdown.<\/td>\n  <\/tr>\n    <tr>\n    <td>-z<\/td>\n    <td>Shutdown using &#8220;software suspend&#8221;. <\/td>\n  <\/tr>\n<\/table>\n<\/p>\n<p>\n<b>Table &#8211; Options to shutdown.<\/b>\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Stopping the System For those of you who hadn&#8217;t noticed, Linux isn&#8217;t like DOS or Windows. Despite the superficial similarity at the command prompt and similarities in the GUI, they have little in common. One very important difference is the &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=230\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-230","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/230\/revisions"}],"predecessor-version":[{"id":711,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/230\/revisions\/711"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}