Top

A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded

BOOT

LSB

  • Linux Standard Base specification (LSB)

    It incorporates, among other things, a means to standardise the implementation of 'init' scripts.

    When installing and removing packaged 'init scripts' LSB compliant package's post-install and post-deinstall/remove scripts call 'install_initd' and 'remove_initd'. Both scripts are in /usr/lib/lsb/.

    Each initd script to be installed/removed by this method must conform to the LSB standard and incorporate a comment header containing information on how it wants to be installed.

  • LSB initd install and remove scripts
    /usr/lib/lsb/install_initd, remove_initd

    Install an LSB compliant init script

    install_initd [/path/to/init.d/script]
    

    It creates the Start/Stop (S../K..) symlinks in the appropriate 'rc...d' directories based on the information in the script header.

    If an init script specifies the following in its comment header file

    # Default-Start: 3 4 5
    # Default-Stop: 0 1 2 6
    

    then 'install_initd' should create

    • Start symbolic links with names starting with 'S' in /etc/rc3.d, /etc/rc4.d, /etc/rc5.d
    • Stop symbolic links with names starting with 'K' in /etc/rc0.d, /etc/rc1.d, /etc/rc2.d, /etc/rc6.d

    Remove an LSB compliant init script

    remove_initd [/path/to/init.d/script]
    

    Remove, deinstall an LSB compliant 'init script' by removing the script's symbolic links in the 'rc*.d' directories.

  • LSB init script Comment header

    At least the following info should be provider in any compliant 'init' script as a comment header

    ### BEGIN INIT INFO
    # Provides:        boot_facility_1 [ boot_facility_2 ...]
    # Required-Start:  boot_facility_1 [ boot_facility_2 ...]
    # Required-Stop:   boot_facility_1 [ boot_facility_2 ...]
    # Should-Start:    boot_facility_1 [ boot_facility_2 ...]
    # Should-Stop:     boot_facility_1 [ boot_facility_2 ...]
    # Default-Start:   run_level_1 [ run_level_2 ...]
    # Default-Stop:    run_level_1 [ run_level_2 ...]
    # Description:     multiline_description
    ### END INIT INFO
    
    Parameter: Value Description
    Provides: boot_facility_1 [boot_facility_2...] Boot facilities provided by this init script. When an init script is run with a start argument, the boot facility(s) specified shall be deemed present and hence init scripts which require those boot facilities should be started later. When an init script is run with a stop argument, the boot facility(s) specified are deemed no longer present.
    Required-Start: boot_facility_1 [boot_facility_2...] Facilities which must be available during startup of this service. The init-script system should insure init scripts which provide the Required-Start facilities are started before starting this script.
    Required-Stop: boot_facility_1 [boot_facility_2...] Facilities which must be available during the shutdown of this service. The init-script system should avoid stopping init scripts which provide the Required-Stop facilities until this script is stopped.
    Should-Start: boot_facility_1 [boot_facility_2...] Facilities which, if present, should be available during startup of this service. This allows for weak dependencies which do not cause the service to fail if a facility is not available. The service may provide reduced functionality in this situation. Conforming applications should not rely on the existence of this feature.
    Should-Stop: boot_facility_1 [boot_facility_2...] Facilities which should be available during shutdown of this service.
    Default-Start: run_level_1 [run_level_2...] Which run levels should by default run the init script with a start (stop) argument to start (stop) the services controlled by the init script e.g. if a service should run in runlevels 3, 4, and 5 only, specify Default-Start: 3 4 5 and Default-Stop: 0 1 2 6.
    Default-Stop: run_level_1 [run_level_2...] See above description
    Short-Description: short_description Provide a brief description of the actions of the init script. Limited to a single line of text.
    Description: multiline_description Provide a more complete description of the actions of the init script. May span multiple lines. In a multiline description, each continuation line shall begin with a # followed by tab character or a # followed by at least two space characters. The multiline description is terminated by the first line that does not match this criteria.
  • LSB initd script management tool
    /sbin/insserv

    Manages installed system init scripts by reading the comment header of the script.

    Command usage

    insserv [options] [/path/to/init.d/]script ...
    insserv [-v] [/path/to/init.d/]script[,start=[,]] ...
    
    Common options:
     -v | --verbose           Write out what is currently going on.
     -n | --dryrun            Do not update symlinks.
     -r | --remove            Remove the space separated list of scripts from all runlevels.
     -d | --default           Use default runlevels defined in the scripts. May restore an 
                              edited runlevel link scheme.
     -f | --force             Ignore if a required service is missed.
    
    Valid runlevels:
     0, 1, 2, 3, 4, 5, 6,
     S,                       S is used during boot into single user mode.
     B                        B is used during boot before any other runlevel.
    
  • Sample insserv configuration file
    /etc/insserv.conf

    'insserv' scans for System Facilities in it's configuration file and each file in the directory /etc/insserv.conf.d/

    Sample, default innserv.conf

    # All local filesystems are mounted (done during boot phase)
    $local_fs  boot               // Each line which begins with $ and a following name defines a system
                                  // facility according to the LSB. All names followed by such a system
                                  // facility will declare the required dependencies of the facility.
    
    # Low level networking
    $network   network route
    
    # Named is operational
    $named     named
    
    # All remote filesystems are mounted 
    # (in some cases /usr may be remote).
    $remote_fs $local_fs nfs
    
    # System logger is operational
    $syslog    syslog
    
    # All network daemons are running
    $netdaemons     portmap inetd
    
    # Services which need to be interactive
    boot.crypto
    

    Names starting with a + sign are marked as optional. If the service with the name is available it will be used, if not available it is ignored silently.

    Words enclosed in <> are keywords. Currently is the only known keyword for marking a service as an interactive one, e.g. a service which requires a passphrase or password input during boot or runlevel change.

  • LSB compliant command
    start_daemon

    Runs the specified program as a daemon.

    Command usage

    start_daemon [-f] [-n nicelevel] 
                 [-p pidfile] pathname [args...]
    
  • LSB compliant command
    killproc

    Send [signal] to all processes that use the specified executable. Default=SIGTERM. If SIGTERM is used and does not terminate a process, SIGKILL is sent after a few seconds (default is 5 seconds, see option '-t').

    Command usage

    killproc [options] [-p pidfile] 
             pathname [signal]
    

    Send SIGTERM to the running sendmail process

    # killproc -TERM /usr/sbin/sendmail
    

    If a pid file 'sendmail.pid' exists in '/var/run/' then the pid from this file is used (after verification) to terminate the Sendmail process. Other running processes are ignored.

    Send SIGTERM to the pid found in /var/myrun/lpd.pid

    # killproc -p /var/myrun/lpd.pid -TERM /usr/sbin/lpd
    

    Sends signal if and only if this pid belongs to '/usr/sbin/lpd'. If the named '/var/myrun/lpd.pid' does not exist, 'killproc' assumes that the daemon of '/usr/sbin/lpd' is not running.

  • LSB compliant command
    pidofproc

    Return one or more process identifiers for a particular daemon.

    Command usage

    pidofproc [-p pidfile] pathname
    
  • LSB compliant command
    startproc

    Starts a process belonging to a particular executable. It checks for processes belonging to the specified executable and starts any. If no processes are found it does not use the pid to search for a process but the full path of the corresponding program.

    Command usage

    startproc [options] 
              /path/to/executable [executable args]
    

    Start /usr/sbin/sendmail if no sendmail process is found

    # startproc /usr/sbin/sendmail
    

    If '/var/run/sendmail.pid' exists it is used to search for a process with an executable that matches '/usr/sbin/sendmail'.

    Start lpd if no process with the pid is found in '/var/myrun/lpd.pid' and there is no existing process that uses the specified binary

    # startproc -p /var/myrun/lpd.pid /usr/sbin/lpd
    
  • LSB compliant command
    checkproc

    Checks for a process by full path name.

    Command usage

    checkproc [-options] [-p pid_file] 
              /full/path/to/executable
    

    Return all pids of running sendmail processes

    # checkproc /usr/sbin/sendmail
    

    Return the command line or the basename of the process pid found in /var/run/lpd.pid

    # checkproc -p /var/myrun/lpd.pid /usr/sbin/lpd
    
  • LSB compliant command
    startpar

    Start runlevel scripts in parallel. Scans the boot and runlevel directories in /etc/init.d/ then executes the appropriate scripts in parallel.

    Command usage

    startpar [options] [-a arg] prg1 prg2 ...
    startpar [options] -M [boot|start|stop]
    
    Options:
     -p                Sets degree of parallelism on one CPU, default is full parallelism.
     -a arg            Provides an argument to all of the scripts
     -t                Buffer timeout
     -T                Timeout works more globally
     -M                Option switches startpar into a make(1) like behaviour
                       three different arguments: 
                       boot | start | stop
                       for reading .depend.boot, .depend.start or .depend.stop in /etc/init.d/
    
  • LSB compliant, SysV style init script management command
    /sbin/chkconfig

    List, add, delete, manage system startup services by manipulating the runlevel links at boot time. It can be thought of as a frontend to 'insserv'.

    Command usage

    chkconfig [options]
    
    Options:
     --list [name]                    List status of all or name service if given.
     --add                            Add service/name rc script file to /etc/init.d
     --del                            Disable/enable a service during boot process
     --override 
     [--level ]      
    

    Display the runlevels system services run at

    # chkconfig --list|more
    ConsoleKit      0:off   1:off   2:off   3:on    4:on    5:on    6:off
    NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
    NetworkManagerDispatcher        0:off   1:off   2:off   3:off   4:off   5:off   6:off
    Anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
    .....
    
  • Debian's install and remove SysV style init script links
    /usr/sbin/update-rc.d

    This is debians alternative to of 'chkconfig', 'insserv' ...

    Command usage

    update-rc.d [options]
    
    Options:
     [-n] [-f] service remove
     [-n] [-f] service defaults [nn | nn-start nn-stop]
     [-n] [-f] service [ start | stop nn runlevel runlevel ...  ] [ start | stop .....] 
    

    Add links for K99foo from /etc/rc0,1,6.d and S99foo from /etc/rc.2,3,4,5.d -> ../init.d/foo

    # update-rc.d foo defaults 99
    

    Remove all K99foo and S99foo links from /etc/rc0-6.d -> /etc/init.d/foo

    # update-rc.d -f foo remove
    

    Add stop links for runlevels 0,1,6 and start links for 2,3,4,5

    # update-rc.d foo stop 99 0 1 6 . start 99 2 3 4 5 .