1.3 Change Runlevels

22Jan - by qkim0x01 - 0 - In /Linux_Admin_Note
101. System Architecture

 

This is a note I made while I was reading a book about Linux

@: Command, +: File, #: Example

 

  • Change Runlevels and Shut Down or Reboot System
    • – runlevel 0
      • – shutdown
    • – runlevel 1
      • – single user mode
    • – runlevel 2
      • – multiuser on Debian
      • – multiuser without NFS file sharing or X Window System (Red hat)
    • – runlevel 3
      • – Defulat multiuser (Red hat)
        • – usually except X Window System
    • – runlevel 4
      • – typically unused
    • – runlevel 5
      • – Full multiuser with GUI (Red hat)
    • – runlevel 6
      • – reboot
    • – init starts all other processes and place the system in default runlevel

 

  • Single User Mode
    • – used for system configuration tasks
      • – to correct problems with corrupt fs and cannot be auto-correct
    • – must be performed with no user activity
    • – done by changing bootloader parameter
      • – add 1 or single at the end of the line
      • – the argument not interpreted by kernel, but pass long to the init process
    • – or # init 1

 

  • Overview of the /etc Directory Tree and the init Process
    • + init and /etc
      • – actions for each runlevel are derived from the style of initialization in Unit System V
        • – and are specified in a series of directories and script files under the /etc directory
    • – When Linux Systems starts
      • – runs scripts in /etc to initial configuration
      • – and switch among runlevels
      • – may differ among distributions
    • /etc/rc.sysinit or /etc/init.d/rcS
      • rc.sysinit
        • – redhat
        • – monolithic init script
      • rcS
        • – running several small scripts
      • – lunched by init process
      • – esential preparation for system
        • – run before any system daemons are started
    • + /etc/rc.local
      • – called after all other init files
        • – (after all system daemon started)
      • – local customizations
        • – affecting system startup
        • – provides an alternative to modifying the other init scripts
      • – modifying rc.sysinit might lost
        • – but modifying rc.local does not lost
    • + /etc/rc
      • – used to changed between runlevels
      • – no Debian
    • – starting and stopping daemons is handled by scrips and symbolic links in /etc/init.d
      • – and by runlevel-specific directories
        • /etc/rc0.d to /etc/rc6.d
      • + /etc/init.d
        • – contains startup/shutdown scripts for each services
          • + ex) /etc/init.d/http
            • – take a single argument
              • – start and stop
              • @ /etc/init.d/http restart
          • – admin can use scripts to start and stop sercies
          • – add new services’ init files could be installed automatically
            • – if not, need to create one
              • – or place startup commands in rc.local
          • – the scripts are not directly executed by the init process
        • + /etc/rc0.d to /etc/rc6.d
          • – contains soft symbolic links to the scripts in /etc/init.d
          • – When init process enter runlevel N,
            • – look throughs all links in rcN.d
          • – KNNname and SNNname
          • – K and S prefixes
            • – kill and start
            • – defines which sercies should run or not
            • – K
              • – mark files for all services should not run
            • – S
              • – mark files for all services are to be running
          • – NN
            • – sequence number
            • – relative order for services to be started or stopped
            • – lower run first
          • – name
          • – since K comes before S,
            • – K services are stopped before S

 

  • Setting the Default Runlevel
    • + /etc/inittab
      • – to determine, init proc reads configuration file in the directory
        • – looking for line containint word initdefault
          • – id:N:initdefault
            • – N is valid runlevel

 

  • Determining Your System’s Runlevel
    • @ runlevel
      • – display previous and current runlevel
        • – if no, print N

 

  • Changing runlevels with init and telinit
    • @ init N
      • – send signals to execute init process
        • – and instructing it to change runlevel
    • @ telinit
      • – link to init
    • – System shutdown with shutdown
      • – when shutdown initiated
        • – all logged on users are notified
        • – further logins are blockes
      • @ shutdown [options] time [warning_message]
        • – shutdown planned matter
        • – default to single user mode
        • – initally use init
        • – time
          • – hh:m
          • – +n
            • – minutes to wait
          • – now
        • – options
          • -f -h -k -r -F
          • -f
            • -fast boot (skips filesystem checks on next boot)
          • -k
            • – just send warning message

 

  • On LPIC
    • – familiar with default runlevels steps for init process

Leave a Reply

Your email address will not be published.