Google


ADBRITE ads links
You are here: CodeIdol.com > Unix > Linux® Quick Fix > The Linux Boot Process > System Shutdown And Rebooting

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

System Shutdown and Rebooting

It is usually not a good idea to immediately power off your system when you are finished using it. This can cause files that are being updated to become corrupted, or worse, you could corrupt the filesystem directory structure. Linux has a number of ways to gracefully shut down and reboot your system, which will be outlined in this section.

Halt/Shut Down the System

The init command enables you to change the current runlevel, and for a shutdown, that value is 0. Here is an example:

     [root@bigboy tmp]# init 0

Fedora also has a shutdown command, which can be used to the same effect. It often prompts you as to whether you are sure you want to execute the command, which can be avoided with the -y switch. The -h switch forces the system to halt, and the first argument tells it how long to wait before starting the procedure, in this case 0 minutes. You can also specify shutting down at a specific time of the day; please refer to the man pages for details. Another advantage of the shutdown command is that it warns people that the shutdown is going to occur:

     [root@bigboy tmp]# shutdown -hy 0

     Broadcast message from root (pts/0) (Sat Nov 6 13:15:27 2004):

     The system is going down for system halt NOW!
     [root@bigboy tmp]#

Reboot the System

You can also use the init command to reboot the system immediately by entering runlevel 6:

     [root@bigboy tmp]# init 6

The reboot command has the same effect, but it also sends a warning message to all users:

     [root@bigboy tmp]# reboot

     Broadcast message from root (pts/0) (Sat Nov 6 12:39:31 2004):

     The system is going down for reboot NOW!
     [root@bigboy tmp]#

More graceful reboots can be done with the shutdown command using the -r switch and specifying a delay, which in this case is 10 minutes:

     [root@bigboy root]# shutdown -ry 10

     Broadcast message from root (pts/0) (Sat Nov 6 13:26:39 2004):

     The system is going DOWN for reboot in 10 minutes!

     Broadcast message from root (pts/0) (Sat Nov 6 13:27:39 2004):

     The system is going DOWN for reboot in 9 minutes!

     ...
     ...
     ...

     Broadcast message from root (pts/0) (Sat Nov 6 13:36:39 2004):

     The system is going down for reboot NOW!

Entering Single-user Mode

Some activities require you to force the system to log off all users, third-party applications, and networking so that only the systems administrator has access to the system from the VGA console. A typical scenario is the addition of a new hard disk, as mentioned in Chapter 27, "Expanding Disk Capacity," or the troubleshooting of a failed boot process.

Another reason is the recovery of your root password.

Switching to Single-user Mode

When the system is running normally, this can be done by using the init command to enter runlevel 1. It is best to do this from the console, because if you do it from a remote terminal session you'll be logged out:

     [root@bigboy root]# init 1
     ...
     ...
     bash-2.05b#

Unfortunately, this gives no prior warning to users, and the shutdown command doesn't have a single-user mode option. This can be overcome by running the shutdown command with a delay in minutes as the only argument:

     [root@bigboy tmp]# shutdown 1

     Broadcast message from root (pts/0) (Sat Nov  6 13:44:59 2004):

     The system is going DOWN to maintenance mode in 1 minute!

     Broadcast message from root (pts/0) (Sat Nov  6 13:45:59 2004):

     The system is going down to maintenance mode NOW!

     ...
     ...
     bash-2.05b#

Entering Single-user Mode at the Grub Splash Screen

You can enter single-user mode directly after turning on the power to your system:

1.
Power on your system.

2.
When the Linux logo screen appears, the one which allows you to select the various installed kernels on the system, type the letter a for "append." You will get a prompt like this to add boot options to the boot string found in your grub.conf file:

grub append> ro root=LABEL=/

3.
Add a 1 to the end of the string:

grub append> ro root=LABEL=/ 1

4.
Press enter. The system will continue to boot, but will go straight to the root # prompt without first asking for a username and password.

Reverting to Your Default runlevel from Single-user Mode

The exit command forces the system to exit runlevel 1 and revert to the default runlevel for the system. You can also use the init command (for example, init 3 and init 5) to alter this default behavior:

     bash-2.05b# exit
     INIT: Entering runlevel: 3
     ...
     ...
     ...
     Fedora Core release 2 (Tettnang)
     Kernel 2.6.8-1.521 on an i686

     bigboy login:

Root Password Recovery

Sometimes you might forget the root password, or the previous systems administrator might move on to a new job without giving it to you. To recover the root password, follow these steps:

1.
Go to the VGA console and press Ctrl-Alt-Del. The system will then shut down in an orderly fashion.

2.
Reboot the system and enter single-user mode.

3.
When at the command prompt, change your password. Single-user mode assumes the person at the console is the systems administrator root, so you don't have to specify a root username.

4.
Return to your default runlevel by using the exit command.

    SAVE
    Digg
    Shown on del.icio.us del.icio.us
    See Whos Talking About This on Technorati Technorati
    I've Reddit reddit

    You are here: CodeIdol.com > Unix > Linux® Quick Fix > The Linux Boot Process > System Shutdown And Rebooting
       
    Related tags







    Popular Categories
    Unix books and guides
    AJAX popular information
    C# language guides
    Windows books and cookbooks
    .......






    © CodeIdol Labs, 2007