1init(1M) System Administration Commands init(1M)
2
3
4
6 init, telinit - process control initialization
7
9 /sbin/init [0123456abcQqSs]
10
11
12 /etc/telinit [0123456abcQqSs]
13
14
16 init is the default primordial user process. (Options given to the ker‐
17 nel during boot may result in the invocation of an alternative primor‐
18 dial user process, as described on kernel(1M)). init initiates the core
19 components of the service management facility, svc.configd(1M) and
20 svc.startd(1M), and restarts these components if they fail. For back‐
21 wards compatibility, init also starts and restarts general processes
22 according to /etc/inittab, as desribed below.
23
24
25 The run levels and system booting descriptions given below are provided
26 for compatibility purposes only, and otherwise made obsolete by the
27 service management facility, smf(5).
28
29 init Failure
30 If init exits for any reason other than system shutdown, it will be
31 restarted with process-ID 1.
32
33 Run Level Defined
34 At any given time, the system is in one of eight possible run levels. A
35 run level is a software configuration under which only a selected group
36 of processes exists. Processes spawned by init for each of these run
37 levels are defined in /etc/inittab. init can be in one of eight run
38 levels, 0−6 and S or s (S and s are identical). The run level changes
39 when a privileged user runs /sbin/init.
40
41 init and System Booting
42 When the system is booted, init is invoked and the following occurs.
43 First, it reads /etc/default/init to set environment variables. This is
44 typically where TZ (time zone) and locale-related environments such as
45 LANG or LC_CTYPE get set. (See the FILES section at the end of this
46 page.) init then looks in /etc/inittab for the initdefault entry (see
47 inittab(4)). If the initdefault entry:
48
49 exists
50
51 init usually uses the run level specified in that entry as the ini‐
52 tial run level to enter only if the options/milestone property has
53 not been specified for svc.startd(1M).
54
55
56 does not exist
57
58 The service management facility, smf(5), examines its configuration
59 specified in svc.startd(1M), and enters the milestone specified by
60 the options/milestone property.
61
62
63
64 The initdefault entry in /etc/inittab corresponds to the following run
65 levels:
66
67 S or s
68
69 init goes to the single-user state. In this state, the system con‐
70 sole device (/dev/console) is opened for reading and writing and
71 the command /sbin/su, (see su(1M)), is invoked. Use either init or
72 telinit to change the run level of the system. Note that if the
73 shell is terminated (using an end-of-file), init only re-initial‐
74 izes to the single-user state if /etc/inittab does not exist.
75
76
77 0-6
78
79 init enters the corresponding run level. Run levels 0, 5, and 6 are
80 reserved states for shutting the system down. Run levels 2, 3, and
81 4 are available as multi-user operating states.
82
83
84
85 If this is the first time since power up that init has entered a run
86 level other than single-user state, init first scans /etc/inittab for
87 boot and bootwait entries (see inittab(4)). These entries are performed
88 before any other processing of /etc/inittab takes place, providing that
89 the run level entered matches that of the entry. In this way any spe‐
90 cial initialization of the operating system, such as mounting file sys‐
91 tems, can take place before users are allowed onto the system. init
92 then scans /etc/inittab and executes all other entries that are to be
93 processed for that run level.
94
95
96 To spawn each process in /etc/inittab, init reads each entry and for
97 each entry that should be respawned, it forks a child process. After it
98 has spawned all of the processes specified by /etc/inittab, init waits
99 for one of its descendant processes to die, a powerfail signal, or a
100 signal from another init or telinit process to change the system's run
101 level. When one of these conditions occurs, init re-examines /etc/init‐
102 tab.
103
104 inittab Additions
105 New entries can be added to /etc/inittab at any time; however, init
106 still waits for one of the above three conditions to occur before re-
107 examining /etc/inittab. To get around this, init Q or init q command
108 wakes init to re-examine /etc/inittab immediately.
109
110
111 When init comes up at boot time and whenever the system changes from
112 the single-user state to another run state, init sets the ioctl(2)
113 states of the console to those modes saved in the file
114 /etc/ioctl.syscon. init writes this file whenever the single-user state
115 is entered.
116
117 Run Level Changes
118 When a run level change request is made, init or a designate sends the
119 warning signal (SIGTERM) to all processes that are undefined in the
120 target run level. A minimum interval of five seconds is observed before
121 init or its designate forcibly terminates these processes by sending a
122 kill signal (SIGKILL). Additionally, init informs svc.startd(1M) that
123 the run level is changing. svc.startd(1M) then restricts the system to
124 the set of services which the milestone corresponding to the run-level
125 change depends on.
126
127
128 When init receives a signal telling it that a process it spawned has
129 died, it records the fact and the reason it died in /var/adm/utmpx and
130 /var/adm/wtmpx if it exists (see who(1)). A history of the processes
131 spawned is kept in /var/adm/wtmpx.
132
133
134 If init receives a powerfail signal (SIGPWR) it scans /etc/inittab for
135 special entries of the type powerfail and powerwait. These entries are
136 invoked (if the run levels permit) before any further processing takes
137 place. In this way init can perform various cleanup and recording func‐
138 tions during the powerdown of the operating system.
139
140 Environment Variables in /etc/default/init
141 You can set default values for environment variables, for such items as
142 timezone and character formatting, in /etc/default/init. See the FILES
143 section, below, for a list of these variables.
144
145 telinit
146 telinit, which is linked to /sbin/init, is used to direct the actions
147 of init. It takes a one-character argument and signals init to take the
148 appropriate action.
149
151 init uses pam(3PAM) for session management. The PAM configuration pol‐
152 icy, listed through /etc/pam.conf, specifies the session management
153 module to be used for init. Here is a partial pam.conf file with
154 entries for init using the UNIX session management module.
155
156 init session required pam_unix_session.so.1
157
158
159
160 If there are no entries for the init service, then the entries for the
161 "other" service will be used.
162
164 0
165
166 Go into firmware.
167
168
169 1
170
171 Put the system in system administrator mode. All local file systems
172 are mounted. Only a small set of essential kernel processes are
173 left running. This mode is for administrative tasks such as
174 installing optional utility packages. All files are accessible and
175 no users are logged in on the system.
176
177 This request corresponds to a request for smf(5) to restrict the
178 system milestone to svc:/milestone/single-user:default.
179
180
181 2
182
183 Put the system in multi-user mode. All multi-user environment ter‐
184 minal processes and daemons are spawned. This state is commonly
185 referred to as the multi-user state.
186
187 This request corresponds to a request for smf(5) to restrict the
188 system milestone to svc:/milestone/multi-user:default.
189
190
191 3
192
193 Extend multi-user mode by making local resources available over the
194 network.
195
196 This request corresponds to a request for smf(5) to restrict the
197 system milestone to svc:/milestone/multi-user-server:default.
198
199
200 4
201
202 Is available to be defined as an alternative multi-user environment
203 configuration. It is not necessary for system operation and is usu‐
204 ally not used.
205
206
207 5
208
209 Shut the machine down so that it is safe to remove the power. Have
210 the machine remove power, if possible.
211
212
213 6
214
215 Stop the operating system and reboot to the state defined by the
216 initdefault entry in /etc/inittab.
217
218 On x86 systems, service svc:/system/boot-config:default is enabled
219 by default. When the config/fastreboot_default property is set to
220 true, init 6 will bypass the firmware.
221
222
223 a,b,c
224
225 Process only those /etc/inittab entries having the a, b, or c run
226 level set. These are pseudo-states, which may be defined to run
227 certain commands, but which do not cause the current run level to
228 change.
229
230
231 Q,q
232
233 Re-examine /etc/inittab.
234
235
236 S, s
237
238 Enter single-user mode. This is the only run level that doesn't
239 require the existence of a properly formatted /etc/inittab file. If
240 this file does not exist, then by default, the only legal run level
241 that init can enter is the single-user mode. When in single-user
242 mode, the filesystems required for basic system operation will be
243 mounted. When the system comes down to single-user mode, these file
244 systems will remain mounted (even if provided by a remote file
245 server), and any other local filesystems will also be left mounted.
246 During the transition down to single-user mode, all processes
247 started by init or init.d scripts that should only be running in
248 multi-user mode are killed. In addition, any process that has a
249 utmpx entry will be killed. This last condition insures that all
250 port monitors started by the SAC are killed and all services
251 started by these port monitors, including ttymon login services,
252 are killed.
253
254 This request corresponds to a request for smf(5) to restrict the
255 system milestone to svc:/milestone/single-user:default.
256
257
259 /dev/console
260
261 System console device.
262
263
264 /etc/default/init
265
266 Contains environment variables and their default values. For exam‐
267 ple, for the timezone variable, TZ, you might specify
268 TZ=US/Pacific. The variables are:
269
270 TZ
271
272 Either specifies the timezone information (see ctime(3C)) or
273 the name of a timezone information file /usr/share/lib/zone‐
274 info.
275
276 Refer to the TIMEZONE(4) man page before changing this setting.
277
278
279 CMASK
280
281 The mask (see umask(1)) that init uses and that every process
282 inherits from the init process. If not set, init uses the mask
283 it inherits from the kernel. Note that init always attempts to
284 apply a umask of 022 before creating a file, regardless of the
285 setting of CMASK
286
287
288 LC_CTYPE
289
290 Character characterization information
291
292
293 LC_MESSAGES
294
295 Message translation
296
297
298 LC_MONETARY
299
300 Monetary formatting information
301
302
303 LC_NUMERIC
304
305 Numeric formatting information
306
307
308 LC_TIME
309
310 Time formatting information
311
312
313 LC_ALL
314
315 If set, all other LC_* environmental variables take-on this
316 value.
317
318
319 LANG
320
321 If LC_ALL is not set, and any particular LC_* is also not set,
322 the value of LANG is used for that particular environmental
323 variable.
324
325
326
327 /etc/inittab
328
329 Controls process dispatching by init.
330
331
332 /etc/ioctl.syscon
333
334 ioctl states of the console, as saved by init when single-user
335 state is entered.
336
337
338 /etc/svc/volatile/init.state
339
340 init state necessary to recover from failure.
341
342
343 /var/adm/utmpx
344
345 User access and administration information.
346
347
348 /var/adm/wtmpx
349
350 History of user access and administration information.
351
352
353 /var/run/initpipe
354
355 A named pipe used for internal communication.
356
357
359 See attributes(5) for descriptions of the following attributes:
360
361
362
363
364 ┌─────────────────────────────┬─────────────────────────────┐
365 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
366 ├─────────────────────────────┼─────────────────────────────┤
367 │Availability │SUNWcsu │
368 └─────────────────────────────┴─────────────────────────────┘
369
371 login(1), sh(1), stty(1), who(1), kernel(1M), shutdown(1M), su(1M),
372 svc.configd(1M), svc.startd(1M), ttymon(1M), ioctl(2), kill(2),
373 ctime(3C), pam(3PAM), init.d(4), inittab(4), pam.conf(4), TIMEZONE(4),
374 utmpx(4), attributes(5), pam_unix_session(5), smf(5), termio(7I)
375
377 If init finds that it is respawning an entry from /etc/inittab more
378 than ten times in two minutes, it assumes that there is an error in the
379 command string in the entry and generates an error message on the sys‐
380 tem console. It then refuses to respawn this entry until either five
381 minutes has elapsed or it receives a signal from a user-spawned init or
382 telinit command. This prevents init from eating up system resources
383 when someone makes a typographical error in the inittab file, or a pro‐
384 gram is removed that is referenced in /etc/inittab.
385
387 init and telinit can be run only by a privileged user.
388
389
390 The S or s state must not be used indiscriminately in /etc/inittab.
391 When modifying this file, it is best to avoid adding this state to any
392 line other than initdefault.
393
394
395 If a default state is not specified in the initdefault entry in
396 /etc/inittab, state 6 is entered. Consequently, the system will loop by
397 going to firmware and rebooting continuously.
398
399
400 If the utmpx file cannot be created when booting the system, the system
401 will boot to state "s" regardless of the state specified in the initde‐
402 fault entry in /etc/inittab. This can occur if the /var file system is
403 not accessible.
404
405
406 When a system transitions down to the S or s state, the /etc/nologin
407 file (see nologin(4)) is created. Upon subsequent transition to run
408 level 2, this file is removed.
409
410
411 init uses /var/run/initpipe, a named pipe, for internal communication.
412
413
414 The pam_unix(5) module is no longer supported. Similar functionality is
415 provided by pam_unix_session(5).
416
417
418
419SunOS 5.11 2 Sep 2009 init(1M)