天天看點

init 指令

  1. Introduce

    NAME

          init, telinit - process control initialization

    SYNOPSIS

          /sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]

          /sbin/telinit [ -t sec ] [ 0123456sSQqabcUu ]

    DESCRIPTION

    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.

    ....

    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 sending 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 privileges.

          The init binary checks if it is init or telinit by looking at its process id; the real init's process id is always 1.  From this it follows that instead of call-ing  telinit  one  can also just  use init instead as a  shortcut.

  2. Related

    # runlevel 0  is  System halt   (Do not use this for initdefault!)

          # runlevel 1  is  Single user mode

          # runlevel 2  is  Local multiuser without remote network (e.g. NFS)

          # runlevel 3  is  Full multiuser with network

         # runlevel 4  is  Not used

         # runlevel 5  is  Full multiuser with network and xdm

         # runlevel 6  is  System reboot (Do not use this for initdefault!)

  3. Example
  •  Switch to xdm

      command : init 5

  •  Switch to runlevel 3

繼續閱讀