Previous Table of Contents Next


Choosing an Init State

The init state (also called run level ) determines what programs are started or initialized when a system is booted. The SunOS system software has eight init states; the default init state for each system is specified in the /etc/inittab file. The default init state for the SunOS 5.x system software is run level 3. See System Init States shows the seven available run levels and the state of the system at each level.

Table 1-1 System Init States

Init State Function
0 Power-down state
1, S, s System administrator state (single-user)
2 Multiuser state (resources not exported)
3 Multiuser state (resources exported)
4 Alternative multiuser state (currently unused)
5 Software reboot state (unused)
6 Reboot

The /sbin/init command is responsible for keeping the system running correctly and is the command you use to change init states. You can also use the init states (with the -i option) as arguments to the shutdown command. There are four types of system states:

  Power-down (run level 0)
  Single-user (run levels 1 and s or S)
  Multiuser (run levels 2 and 3)
  Reboot (run levels 5 and 6)

When preparing to do a system administration task, you need to determine which init state is appropriate for the system and the task at hand.

Finding the Run Level for a System

To find the run level for a system, type who -r and press Return. The run level, date and time, process termination status, process ID, and process exit status are displayed.

In this example, the system named drusilla is at the default multiuser run level (3), the date and time are Feb 6 15:46, the process termination status is 3, the process ID is 0, and process exit status is S:

drusilla% who -r
   .     run-level 3  Feb 6 15:46    3     Ø S
drusilla%

The next sections describe how you might use each init state.

Using Power-Down State, Run Level 0

Use this level to shut down the system so that it is safe to turn off the power.

Using System Administrator State, Run Level 1

Use this level when performing administrative tasks that require you to be the only user on the system. Root and /usr are the only file systems mounted, and you can access only minimum kernel utilities. The terminal from which you issue the init 1 command becomes the console. No other users are logged in.

Using Multiuser State, Run Level 2

Use this level for normal operations. Multiple users can access the system and the entire file system. All daemons are running except for NFS server, syslog, and remote file sharing.


NOTE:  A daemon is a special type of program that, once activated, starts itself and carries out a specific task without any need for user input. Daemons typically are used to handle jobs that have been queued, such as printing, mail, and communication.

Using Remote Resource-Sharing State, Run Level 3

Use this level for normal operations with NFS resource-sharing available.

Using Alternative Multiuser State, Run Level 4

This level currently is unavailable.

Using Interactive Reboot State, Run Level 5

Use this level when you want to be prompted for a device other than the default boot devices. You can also change to this level using the reboot -a command.

Using Reboot State, Run Level 6

Use this level to shut down the system to run level 0, and then reboot to multiuser level (or to whatever level is the default in the inittab file).

Using Single - User State, Run Level s or S

Use this level to run as a single user with all file systems mounted and accessible.

Changing Run Levels

Use either the telinit or init command to change run levels. The telinit command takes a one-character argument that tells init what run level to use. Although you can use the init command directly, telinit is the preferred command to use to change system run states.

To change run levels:

1.  Become superuser.
2.  Type telinit n and press Return. Replace the variable n with the number of the init state you want to use.

To shut down the system:

oak% su
Password:
# telinit Ø

To change to single-user state:

oak% su
Password:
# telinit 1

To change to multiuser state, with no NFS server daemons:

oak% su
Password:
# telinit 2

To change to multiuser state, with NFS server daemons:

oak% su
Password:
# telinit 3

To shut down and reboot a system:

oak% su
Password:
# telinit 6

Choosing Which Shutdown Command to Use

When preparing to do a system administration task, you need to determine which shutdown command is appropriate for the system and the task at hand. The next sections describe how you might use each of the available shutdown commands:

  /usr/sbin/shutdown
  /etc/telinit and /sbin/init
  /usr/sbin/halt
  /usr/sbin/reboot

These commands, respectively, initiate shutdown procedures, kill all running processes, write out any new data to the disk, and shut down the SunOS 5.x system software to the appropriate run level.

shutdown

Use the shutdown command when shutting down a system with multiple users. The shutdown command sends a warning message to all users who are logged in, waits 60 seconds (the default), and then shuts down the system to single-user state. You can choose a different default wait time.


Previous Table of Contents Next