Chinaunix首页 | 论坛 | 博客

分类: LINUX

2009-01-22 15:34:14

NAME
       init, telinit - process control initialization
       控制初始化的进程。
 
SYNOPSIS
       /sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]
       /sbin/telinit [ -t sec ] [ 0123456sSQqabcUu ]
 
DESCRIPTION
   Init
       Init  is  the  parent  of all processes.  Its primary role is to
       create processes from a script stored in the  file  /etc/inittab
       (see  inittab(5)).   This  file  usually has entries which cause
       init to spawn gettys on each line that users  can  log  in.   It
       also  controls  autonomous  processes required by any particular
       system.
       init是所有进程的父进程。她主要的角色就是从/etc/inittab这个脚本中创建许多的进程。inittab配置文档中通常具有一些条目,这些条目能初始化每行从spawn gettys登录的用户。她也能够控制特定系统要求的自治进程。
 
RUNLEVELS
       A runlevel is a  software  configuration  of  the  system  which
       allows  only  a  selected group of processes to exist.  The pro-
       cesses spawned by init for each of these runlevels  are  defined
       in  the  /etc/inittab  file.   Init  can be in one of eight run-
       levels: 0-6 and S or s.  The runlevel is  changed  by  having  a
       privileged  user run telinit, which sends appropriate signals to
       init, telling it which runlevel to change to.

       运行级别是系统定义的软件,只允许一个被选定的进程组存在。通过初始化每一个在inittab配置文件定义了的运行级别,运行级别产生大量进程。init被八个运行级别定义,这八个运行级别是0-6 和S ,s。一个私有用户通过telinit改变运行级别。telinit 发送适当信号给init,告诉init哪一个运行级别被改变。
 
       Runlevels 0, 1, and 6 are reserved. Runlevel 0 is used  to  halt
       the  system,  runlevel  6 is used to reboot the system, and run-
       level 1 is used to get the system down into  single  user  mode.
       Runlevel S is not really meant to be used directly, but more for
       the scripts that are executed when entering runlevel 1. For more
       information  on this, see the manpages for shutdown(8) and init-
       tab(5).

       运行级别0,1和6是被保留的。运行级别0被用来终止系统。运行级别6被用来重新启动系统。运行级别1用来使用单人模式登录系统。运行级别S表示不是直接被使用。使用运行级别1的时候,脚本里的都不被执行。想知道更多的信息请参考shutdown(8)和inittab(5)
 
       Runlevels 7-9 are also valid, though not really documented. This
       is  because "traditional" Unix variants don’t use them.  In case
       you‘re curious, runlevels S and s are in fact the same.   Internally they are aliases for the same runlevel.
       运行级别7-9也是有效的,尽管没有真实的文档。这是因为传统的unix系统变种不会使用7-9,假使你好奇,运行级别S和s实际上是一样的。S和s是同一个运行级别的别名。

BOOTING
       After  init  is  invoked  as  the  last  step of the kernel boot
       sequence, it looks for the file /etc/inittab to see if there  is
       an  entry  of the type initdefault (see inittab(5)). The initde-
       fault entry determines the initial runlevel of the  system.   If
       there  is  no such entry (or no /etc/inittab at all), a runlevel
       must be entered at the system console.

      作为系统内核启动顺序的最后一步, 在init被请求之后,init寻找/etc/inittab,看inittab里是否有默认运行级别类型的条目,默认运行级别的条目决定了系统初始化运行级别。如果没有这样的条目或者根本没有inittab,则在系统控制台内必须输入运行级别。
 
       Runlevel S or s bring the system to single user mode and do  not
       require an /etc/inittab file.  In single user mode, a root shell
       is opened on /dev/console.
运行级别S或者s将系统带到单人用户模式,而不要求inittab配置文件,在单人模式下,一个root用户shell被打开。
 
       When entering single user mode, init  initializes  the  consoles
       stty settings to sane values. Clocal mode is set. Hardware speed
       and handshaking are not changed.
       当进入单人用户模式init初始化控制台设定一个健全的登录环境,设置本地模式,不改变硬件速度和握手。
 
       When entering a multi-user mode for the first  time,  init  performs  the boot and bootwait entries to allow file systems to be mounted before users can log in.  Then all entries matching the runlevel are processed.
       当第一次进入多用户模式,init执行boot 和bootwait条目,允许在用户登录前挂载文件系统。那么所有的条目合并成运行级别被处理。
 
       When  starting a new process, init first checks whether the file
       /etc/initscript exists. If it does, it uses this script to start
       the process.
       当开始一个新进程,init先检查/etc/initscript文件是否存在。如果存在,init使用这个脚本文件启动这个进程。
 
       Each time a child terminates, init records the fact and the rea-
       son it died in /var/run/utmp and  /var/log/wtmp,  provided  that
       these files exist.

       在每一子终端,假如utmp和wtmp存在,init在 /var/run/utmp 和 /var/log/wtmp记录终端的死亡和死亡的原因,
 
CHANGING RUNLEVELS
       After  it has spawned all of the processes specified, init waits
       for one of its descendant processes to die, a powerfail  signal,
       or  until  it is signaled by telinit to change the system鈥檚 run-
       level.  When one of the above three conditions  occurs,  it  re-
       examines  the  /etc/inittab  file.   New entries can be added to
       this file at any time.  However, init still waits for one of the
       above  three  conditions  to occur.  To provide for an instanta-
       neous response, the telinit Q or q command can wake up  init  to
       re-examine the /etc/inittab file.
 
       If init is not in single user mode and receives a powerfail sig-
       nal (SIGPWR), it reads the file /etc/powerstatus. It then starts
       a command based on the contents of this file:
 
       F(AIL) Power is failing, UPS is providing the power. Execute the
              powerwait and powerfail entries.
 
       O(K)   The power has  been  restored,  execute  the  powerokwait
              entries.
 
       L(OW)  The  power is failing and the UPS has a low battery. Exe-
              cute the powerfailnow entries.
 
       If /etc/powerstatus doesn鈥檛 exist or contains anything else then
       the  letters  F,  O or L, init will behave as if it has read the
       letter F.
 
       Usage of SIGPWR and  /etc/powerstatus  is  discouraged.  Someone
       wanting  to  interact with init should use the /dev/initctl con-
       trol channel - see the source code of the sysvinit  package  for
       more documentation about this.
 
       When  init  is  requested  to  change the runlevel, it sends the
       warning signal SIGTERM to all processes that  are  undefined  in
       the  new runlevel.  It then waits 5 seconds before forcibly ter-
       minating these processes via the SIGKILL signal.  Note that init
       assumes  that all these processes (and their descendants) remain
       in the same process group  which  init  originally  created  for
       them.   If  any process changes its process group affiliation it
       will not receive these signals.  Such processes need to be  ter-
       minated separately.
 
TELINIT
       /sbin/telinit is linked to /sbin/init.  It takes a one-character
       argument and signals init to  perform  the  appropriate  action.
       The following arguments serve as directives to telinit:
 
       0,1,2,3,4,5 or 6
              tell init to switch to the specified run level.
 
       a,b,c  tell init to process only those /etc/inittab file entries
              having runlevel a,b or c.
 
       Q or q tell init to re-examine the /etc/inittab file.
 
       S or s tell init to switch to single user mode.
 
       U or u tell init to re-execute itself (preserving the state). No
              re-examining  of  /etc/inittab  file  happens.  Run level
              should be one of  Ss12345,  otherwise  request  would  be
              silently ignored.
 
       telinit can also tell init how long it should wait between send-
       ing processes the SIGTERM and SIGKILL signals.  The default is 5
       seconds, but this can be changed with the -t sec option.
 
       telinit  can  be  invoked  only by users with appropriate privi-
       leges.
 
       The init binary checks if it is init or telinit  by  looking  at
       its  process  id;  the real init鈥檚 process id is always 1.  From
       this it follows that instead of calling  telinit  one  can  also
       just use init instead as a shortcut.
 
ENVIRONMENT
       Init  sets the following environment variables for all its chil-
       dren:
 
       PATH   /bin:/usr/bin:/sbin:/usr/sbin
 
       INIT_VERSION
              As the name says. Useful to determine if  a  script  runs
              directly from init.
 
       RUNLEVEL
              The current system runlevel.
 
       PREVLEVEL
              The previous runlevel (useful after a runlevel switch).
 
       CONSOLE
              The  system  console.  This  is really inherited from the
              kernel; however if it is not set  init  will  set  it  to
              /dev/console by default.
 
BOOTFLAGS
       It  is  possible to pass a number of flags to init from the boot
       monitor (eg. LILO). Init accepts the following flags:
 
       -s, S, single
            Single user mode boot. In this mode /etc/inittab  is  exam-
            ined  and  the bootup rc scripts are usually run before the
            single user mode shell is started.
 
       1-5  Runlevel to boot into.
 
       -b, emergency
            Boot directly into a single user shell without running  any
            other startup scripts.
 
       -a, auto
            The  LILO  boot  loader adds the word "auto" to the command
            line if it booted the kernel with the default command  line
            (without  user  intervention).   If this is found init sets
            the "AUTOBOOT" environment variable to "yes". Note that you
            cannot  use  this for any security measures - of course the
            user could specify "auto" or -a on the command  line  manu-
            ally.
 
       -z xxx
            The  argument  to -z is ignored. You can use this to expand
            the command line a bit, so that it takes some more space on
            the  stack.  Init  can  then manipulate the command line so
            that ps(1) shows the current runlevel.
 
INTERFACE
       Init listens on a fifo  in  /dev,  /dev/initctl,  for  messages.
       Telinit uses this to communicate with init. The interface is not
       very well documented or finished. Those interested should  study
       the  initreq.h  file in the src/ subdirectory of the init source
       code tar archive.
 
SIGNALS
       Init reacts to several signals:
 
       SIGHUP
            Has the same effect as telinit q.
 
       SIGUSR1
            On receipt of this signals, init closes  and  re-opens  its
            control  fifo,  /dev/initctl.  Useful  for bootscripts when
            /dev is remounted.
 
       SIGINT
            Normally the kernel sends this signal to  init  when  CTRL-
            ALT-DEL is pressed. It activates the ctrlaltdel action.
 
       SIGWINCH
            The kernel sends this signal when the KeyboardSignal key is
            hit.  It activates the kbrequest action.
 
CONFORMING TO
       Init is compatible with the System  V  init.  It  works  closely
       together  with  the  scripts  in the directories /etc/init.d and
       /etc/rc{runlevel}.d.  If your system uses this convention, there
       should  be a README file in the directory /etc/init.d explaining
       how these scripts work.
 
FILES
       /etc/inittab
       /etc/initscript
       /dev/console
       /var/run/utmp
       /var/log/wtmp
       /dev/initctl
 
WARNINGS
       Init assumes that processes and descendants of processes  remain
       in the same process group which was originally created for them.
       If the processes change their group, init can鈥檛  kill  them  and
       you  may  end  up  with  two processes reading from one terminal
       line.
 
DIAGNOSTICS
       If init finds that it is continuously respawning an  entry  more
       than  10  times  in  2  minutes, it will assume that there is an
       error in the command string, generate an error  message  on  the
       system  console, and refuse to respawn this entry until either 5
       minutes has elapsed or it receives a signal.  This  prevents  it
       from eating up system resources when someone makes a typographi-
       cal error in the /etc/inittab file or the program for the  entry
       is removed.
 
阅读(2171) | 评论(0) | 转发(0) |
0

上一篇:inittab详解

下一篇:解释init.d

给主人留下些什么吧!~~