• Aucun résultat trouvé

Initial processes: / etc/ ini ttab

Dans le document A / UX® Local System Administration (Page 72-76)

An overview of the initial processes follows; For more complete information, refer to the

init(1) man page. The system's topmost program is init, initial process. It is the first process to run after you boot the system. The ini t program spawns processes as specified in the /ete/inittab file.

One of the first commands in it executes is the / e t e / s y sin it r e shell program, which performs such basic functions as setting the system's clock.

The next line in /ete/ inittab specifies the default initial run level:

is:2:initdefault: #First Init State

Chapter 2 System Startup and Shutdown 2-35

The run level in the /etc/ inittab file is specified in the second field of each entry, in this case 2 for "multi-user." Once the initial run level is determined, ini t processes only those

/ et c / ini t tab entries whose rnn-level field is the same as the run level currently in effect.

If you check the contents of / etc / in i t t ab on your system, you will see the processes invoked by init. For example, the following processes started by init are found in

/ etc/ inittab. (The process names are preceded by an id and a rnn-level, as discussed in ~ the next section.)

/ etc/bcheckrc A startup script that runs f sck on those file systems other than root.

/etc/bre

/etc/rc

fete/getty

A startup script that sets the permissions on pseudo-t t y s.

A startup script that mounts the file systems (if applicable) and performs some general housekeeping.

A process that enables logins on serial ports. See Chapter 3, "User and Group Administration," and Chapter 7, "Managing Other Peripheral Devices."

/etc/inittab entry format

Each line in / etc / in i t t ab is an entry containing four fields separated by colons and

followed by an optional number sign (#) and an optional comment. The format of each entry is id: rnn-level:action: command

where id rnn-level action command

Unique entry identification

Run level at which the entry is processed Action to be taken with next field Command to be executed

2-36 A!UX Local System Administration

030-0762-A

For example, the following line in the / et c / ini t tab file is distributed with the standard system:

co::respawn:/etc/loginrc #spawn Login or getty for console Comments about the line are preceded by a number sign (#). These comments indicate that the line refers to the console port. Because the action field is set to respawn, this port is enabled in multi-user mode. This is explained in more detail in the discussion of the action field that follows.

The id field is an arbitrary identifier of one to four characters that makes the entry unique.

Although the identifier is arbitrary, convention dictates that the identifier for an entry that affects a port be the corresponding port number. In the id field of the above line, co refers to the console port.

The run-level field tells ini t whether to process the entry. The run-level field can be any number from 0 to 6 (2, for multi-user, is the most common). If the run-level field is empty, ini t processes the entry at all run levels.

The action field specifies how to execute the command field if the entry's run-level field

Tells the system to run this command when the designated run level is entered. If the command terminates for any reason, the system should run it again. If you specify respawn as the action field, the command runs whenever the run level matches the run level of the entry. If you leave the

run-level field empty, the process runs at all times and all run levels.

Tells the system to turn off this command for all run levels.

Tells the system to tum on this command for this run level. If the command

The fourth field is the command to be executed. When the run level of each entry matches the default run level, the command named in the fourth field is executed. In the above example, the command /etc/loginrc would be executed for each entry in the /etc/inittab file whose command field is / etc/ loginrc and whose action field is respawn, as modified by the action field.

Changing run levels: ini t

Once the system is started and running at the default run level, you can change the run level.

Log in to the console emulator as the superuser and enter init run-level

where run-level is an argument to ini t that may be either a value from 0 to 6, or the letter s or S. See init(1M) in A/UX System Administrator's Reference.

When you enter this command, init scans /etc/inittab again, kills processes that should not be active in the new run level, except for those that spawn daemons (see the discussion of ini t Q later in this section), and activates those entries whose run-level value is the same as that of the new run level, leaving all other processes untouched.

For instance, if the following lines appear in /etc/inittab 01:23:respawn:/etc/getty ttyl at_9600

02:2:respawn:/etc/getty tty2 at 9600

both ports ttyl and tty2 are running a getty command when the system is at run level 2.

But if you later type in it 3

the getty running to tty2 is terminated, whereas the one running to ttyl continues because both run level 2 and run level 3 are specified for that port.

The only way to modify how a process runs at a new run level is to specify it in

/etc/inittab. In theory, you should specify every process that affects, for instance, a port, with reference to every single possible run level. In practice, you do that only for those processes that you may want to tum on and off for certain specific run levels. See Chapter 7,

"Managing Other Peripheral Devices," for examples.

2-38 AlUX Local System Administration

030-0762-A

\

If you introduce a change in / et c / in i t t ab, enter

init Q

to make the change known to the system without restarting it. This command forces in it to reread /etc/inittab. Some of the processes controlled by init spawn child processes, however, and these child processes are not terminated by the ini t Q command. You can terminate these processes individually by specifying their process ID number to the k i l l

command, or by shutting down the system and rebooting.

The general functioning of your system is determined by the current run level. The current run level is determined at startup by the default entry in / etc/ ini ttab, and it can be changed via the ini t command. The current run level determines which commands (in the command field of /etc/inittab entries) are activated.

When running init, you should be careful not to bring about any changes that would disrupt the activities of users currently logged in. For instance, in it could disrupt an operating modem if a getty command were sent to that port. Know your run states and make sure that changing them will not disrupt user activity.

Dans le document A / UX® Local System Administration (Page 72-76)