Contact us |
Starting Up and changing runlevelsTable of contents:PreambleShutdown and Reboot the system properlyThere are various scripts/methods that can be used in rebooting, shutting down (halting) the system. In-order to avoid corrupting the file system and to also avoid disrupting the work of various users that might be logged on to the system, it is important to follow proper procedures in shutting or rebooting the system. Some of the procedures can give the logged on users adequate warning to save their work before the system goes down and others do not. This lab explores the various ways. It uses - shutdown, reboot and init (change in the runlevel) SHUTDOWNUsage: shutdown [-akrhfnc] [-t secs] time [warning message] -a: use /etc/shutdown.allow -k: don't really shutdown, only warn. -r: reboot after shutdown. -h: halt after shutdown. -f: do a 'fast' reboot (skip fsck). -F: Force fsck on reboot. -n: do not go through "init" but go down real fast. -c: cancel a running shutdown. -t secs: delay between warning and kill signal. ** the "time" argument is mandatory! (try "now") ** HALT, REBOOT, POWEROFF SYNOPSIS /sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] /sbin/reboot [-n] [-w] [-d] [-f] [-i] /sbin/poweroff [-n] [-w] [-d] [-f] [-i]
DESCRIPTION
Halt logs that the system is being brought down in the
file /var/log/wtmp, and then either tells the kernel to
halt, reboot or poweroff the system.
OPTIONS
-n Don't sync before reboot or halt.
-w Don't actually reboot or halt but only write the wtmp record (in the
/var/log/wtmp file).
-d Don't write the wtmp record. The -n flag implies
-f Force halt or reboot, don't call shutdown(8).
-i Shut down all network interfaces just before halt or reboot.
-p When halting the system, do a poweroff.
INIT, TELINIT - PROCESS CONTROL INITIALIZATION SYNOPSIS /sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ] /sbin/telinit [ -t sec ] [ 0123456sSQqabcUu ] Exercise 1 Starting Up and changing runlevelsIn this exercise you will reboot and shutdown the computer properly To use the shutdown and reboot commands1. At the Login prompt, type “root ” and press [ENTER] 2. At the password prompt type “password” and press [ENTER] 3. While logged into the system as the superuser (root), reboot the system after 2 minutes delay: Type [root@localhost root]# shutdown –r 2 Broadcast message from root (pts/0) Thu Apr 25 19:13:25 2002... The system is going DOWN for reboot in 2 minutes !! The above message will be seen on the terminals of all logged on users 4. After the system reboots, log into the system and try the “reboot” command. Type: [root@localhost root]# reboot To use the init commandAfter the system reboots, you will change the current runlevel to reboot the system again 1. Log in as root 2. Type in the password - "password" 3. Find out the current runlevel. Type: [root@localhost root]# runlevel N 3 The above shows that you are currently in runlevel 3. (i.e. Command line multi-user mode) 5. Change to runlevel 6 (runlevel 6 is interpreted by most versions of Linux to mean reboot) [root@localhost root]# init 6 The system will go down for an immediate reboot without any warning message. To shutdown the system without rebootingNext you will shutdown the system without rebooting. 1. While logged in as root, first send a customized test warning message to the console of all logged on users without actually bring down the system. The message you will send is “ I am going out for lunch break “. Type: [root@localhost root]# shutdown -k now "I am going out for lunch" Broadcast message from root (pts/4) (Tue Jan 7 17:00:12 1943): I am going out for lunch The system is going down to maintenance mode NOW! Do you know what the “now” in the command above does? 2. Now do an actual shutdown of the system after 2 minutes. Type: [root@localhost root]# shutdown -h 2 Broadcast message from root (pts/1) (Tue Jan 7 17:13:32 1943): The system is going DOWN for system halt in 2 minutes! To poweroff the system1. If your system isn’t powered on, turn it on and log in as the superuser. 2. Use the poweroff command to bring down the system. Type: [root@localhost root]# poweroff 3. Experiment with the “ halt ” command.
|
Login... |