Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Apress - Books for Professionals by Professionals

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 72 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

init



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.


RUNLEVELS

       A runlevel is a software configuration of the system which
       allows  only  a selected group of processes to exist.  The
       processes spawned by init for each of these runlevels  are
       defined  in  the /etc/inittab file.  Init can be in one of
       eight runlevels: 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.

       Runlevels  0, 1, and 6 are reserved. Runlevel 0 is used to
       halt the system, runlevel 6 is used to reboot the  system,
       and  runlevel 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 inittab(5).

       Runlevels  7-9  are  also  valid,  though not really docu­
       mented. 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.


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 init­
       tab(5)). The initdefault entry determines the initial run­
       level  of  the  system.   If there is no such entry (or no
       /etc/inittab at all), a runlevel must be  entered  at  the
       system console.

       Runlevel  S  or s bring the system to single user mode and
       do not require an /etc/inittab file.  In single user mode,
       /sbin/sulogin is invoked on /dev/console.

       script to start the process.

       Each  time  a  child terminates, init records the fact and
       the reason it died  in  /var/run/utmp  and  /var/log/wtmp,
       provided that these files exist.


CHANGING RUNLEVELS

       After  it has spawned all of the processes specified, init
       waits for one of its descendant processes to die, a power­
       fail  signal, or until it is signaled by telinit to change
       the system's runlevel.  When one of the above three condi­
       tions  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  instantaneous  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  power­
       fail  signal (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. Exe­
              cute 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.
              Execute the powerfailnow entries.

       If /etc/powerstatus doesn't  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. Some­
       one   wanting   to  interact  with  init  should  use  the
       /dev/initctl control 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 unde­
       fined in the new runlevel.  It then waits 5 seconds before
       forcibly terminating these processes via the SIGKILL  sig­
       nal.  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 terminated separately.


TELINIT


       U or u tell init  to  re-execute  itself  (preserving  the
              state).  No  re-examining of /etc/inittab file hap­
              pens. 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 calling telinit one
       can also just use init instead as a shortcut.


ENVIRONMENT

       Init sets the following environment variables for all  its
       children:

       PATH   /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin

       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
            examined and the bootup rc scripts  are  usually  run
            before the single user mode shell is started.

       1-5  Runlevel to boot into.
            "auto" or -a on the command line manually.

       -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 run­
            level.


INTERFACE

       Init listens on a fifo in  /dev,  /dev/initctl,  for  mes­
       sages.   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
            Init looks for /etc/initrunlvl and  /var/log/initrun­
            lvl.   If  one  of  these  files exist and contain an
            ASCII runlevel, init switches to  the  new  runlevel.
            This  is  for backwards compatibility only! .  In the
            normal case (the files don't exist) init behaves like
            telinit q was executed.

       SIGUSR1
            On  receipt of this signals, init closes and re-opens
            it's   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/init.d/rc{runlevel}.d.  If your  sys­
       tem uses this convention, there should be a README file in
       the directory /etc/init.d  explaining  how  these  scripts
       work.
       can't 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 mes­
       sage 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 typographical error in the /etc/init­
       tab file or the program for the entry is removed.


AUTHOR

       Miquel van Smoorenburg (miquels@cistron.nl), initial  man­
       ual  page by Michael Haardt (u31b3hs@pool.informatik.rwth-
       aachen.de).


SEE ALSO

       init.d(7), getty(1), login(1), sh(1),  runlevel(8),  shut­
       down(8), kill(1), inittab(5), initscript(5), utmp(5)

                          23 August 2001                  INIT(8)
  

The Linux Tutorial is always looking for new contributors.


Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can get all the latest Site and Linux news by checking out our news page.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.08 Seconds