LPI-1 Linux Certification – SysV Startup Sequence

SysV startup sequence

OS startup sequence (SysV) Debian Red Hat
At startup /sbin/init executes all instructions on /etc/inittab . This script at first switches to the default runlevel… id:2:initdefault: id:5:initdefault:
… then it runs the following script (same for all runlevels) which configures peripheral hardware, applies kernel parameters, sets hostname, and provides disks initialization… /etc/init.d/rcS /etc/rc.d/rc.sysinit or/etc/rc.sysinit
… and then, for runlevel N, it calls the script/etc/init.d/rc N (i.e. with the runlevel number as parameter) which launches all services and daemons specified in the following startup directories: /etc/rcN.d/ /etc/rc.d/rcN.d/

The startup directories contain symlinks to the init scripts in /etc/init.d/ which are executed in numerical order. Links starting with K are called with argument stop, links starting with S are called with argument start.

lrwxrwxrwx. 1 root root   14 Feb 11 22:32 K88sssd -> ../init.d/sssd
lrwxrwxrwx. 1 root root   15 Nov 28 14:50 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root   17 Nov 28 15:01 S01sysstat -> ../init.d/sysstat
lrwxrwxrwx. 1 root root   18 Nov 28 14:54 S05cgconfig -> ../init.d/cgconfig
lrwxrwxrwx. 1 root root   16 Nov 28 14:52 S07iscsid -> ../init.d/iscsid
lrwxrwxrwx. 1 root root   18 Nov 28 14:42 S08iptables -> ../init.d/iptables

 

The last script to be run is S99local -> ../init.d/rc.local ; therefore, an easy way to run a specific program on boot is to add it to this script file.

/etc/init.d/boot.local   runs only at boot time, not when switching runlevel.

/etc/init.d/before.local (SUSE) runs only at boot time, before the scripts in the startup directories.

/etc/init.d/after.local     (SUSE) runs only at boot time, after the scripts in the startup directories.

 

Debian Red Hat
To add or remove services at boot sequence: update-rc.d service defaults update-rc.d -f service remove chkconfig –add service chkconfig –del service
Parameters supported by the init scripts
start Start the service Mandatory
stop Stop the service
restart Restart the service (stop, then start)
status Display daemon PID and execution status
force-reload Reload configuration if the service supports this option, otherwise restart the service
condrestart try-restart Restart the service only if already running Optional
reload Reload service configuration

/etc/init.d/service start

service service start    (Red Hat)                Start a service

rcservice start              (SUSE)

LPI-1 Linux Certification – Runlevels

Runlevel Debian Red Hat
0 Shutdown
1 Single user / maintenance mode
2 Multi-user mode (default) Multi-user mode without network
3 Multi-user mode Multi-user mode with network
4 Multi-user mode Unused, for custom use
5 Multi-user mode Multi-user mode with network and X(default)
6 Reboot
S Single user / maintenance mode (usually accessed through runlevel 1)

The default runlevels are 2 3 4 5

 

who -r

runlevel

Display the previous and the current runlevel
telinit runlevel

init runlevel

init 0

telinit 0

Change runlevel
shutdown -h now

halt

poweroff

init 6

telinit 6

Halt the system
shutdown -r now

reboot

Reboot the system
shutdown Shut down the system in a secure way: all logged in users are notified via a message to their terminal, and login is disabled.

This command can be run only by the root user and by those users (if any) listed in

/etc/shutdown.allow

shutdown -h 16:00 message Schedule a shutdown for 4 PM and send a warning message to all logged in users
shutdown -a Non-root users that are listed in /etc/shutdown.allow can use this command to shut down the system
shutdown -f Skip fsck on reboot
shutdown -F Force fsck on reboot
shutdown -c Cancel an already running shutdown

 

LPI-1 Linux Certification – Boot sequence

POST (Power-On Self Test) Low-level check of PC hardware.
BIOS(Basic I/O System) Detection of disks and hardware.
Chain loaderGRUB
(GRand Unified Bootloader)
GRUB stage 1 is loaded from the MBR and executes GRUB stage 2 from filesystem.GRUB chooses which OS to boot on.The chain loader hands over to the boot sector of the partition on which resides the OS.

The chain loader also mounts initrd, an initial ramdisk (typically a compressed ext2 filesystem) to be used as the initial root device during kernel boot; this make possible to load kernel modules that recognize hard drives hardware and that are hence needed to mount the real root filesystem. Afterwards, the system runs /linuxrc with PID 1. (From Linux 2.6.13 onwards, the system instead loads into memory initramfs, a cpiocompressed image, and unpacks it into an instance of tmpfs in RAM. The kernel then executes /init from within the image.)

inux kernel Kernel decompression into memory.Kernel execution.Detection of devices.

The real root filesystem is mounted on / in place of the initial ramdisk.

init Execution of init, the first process (PID 1).The system tries to execute in the following order:/sbin/init

/etc/init

/bin/init

/bin/sh

If none of these succeeds, the kernel will panic.

Startup The system loads startup scripts and runlevel scripts.
X Server (Optional) The X Display Manager starts the X Server.

Some newer systems use UEFI (Unified Extensible Firmware Interface). UEFI does not use the MBR boot code; it has knowledge of partition table and filesystems, and stores its application files required for launch in a EFI System Partition, mostly formatted as FAT32.

After the POST, the system loads the UEFI firmware which initializes the hardware required for booting, then reads its Boot Manager data to determine which UEFI application to launch. The launched UEFI application may then launch another application, e.g. the kernel and initramfs in case of a boot loader like the GRUB.

LPI-1 Linux Certification – Determine And Configure Hardware Settings

Topic 101: System Architecture

101.1 Determine and configure hardware settings

  • Weight: 2
  • Description: Candidates should be able to determine and configure fundamental system hardware.

Key Knowledge Areas

  • Enable and disable integrated peripherals.
  • Configure systems with or without external peripherals such as keyboards.
  • Differentiate between the various types of mass storage devices.
  • Set the correct hardware ID for different devices, especially the boot device.
  • Know the differences between coldplug and hotplug devices.
  • Determine hardware resources for devices.
  • Tools and utilities to list various hardware information (e.g. lsusb, lspci, etc.)
  • Tools and utilities to manipulate USB devices
  • Conceptual understanding of sysfs, udev, hald, dbus

Terms and Utilities

  • /sys
  • /proc
  • /dev
  • modprobe
  • lsmod
  • lspci
  • lsusb

 


General System Information Tools/Utilities

  • cat /var/log/messages — is the same as dmesg
  • dmesg — kernel messages given during booting.
  • tail -f /var/log/messages – shows last 10 lines and keep outputting new lines
  • uname -a — brief OS and kernel information.

Memory Diagnostic Tools/Utilities

  • cat /proc/meminfo — static information about your RAM
  • top — real-time RAM and CPU utilization printout
  • free — current memory/swap utilization.

CPU Diagnostic Tools/Utilities

  • hwinfo –cpu — static information about your CPU

Disk and File System Diagnostic Tools/Utilities

  • cat /etc/fstab — show configuration file for file system mounting.
  • df -h — current disk space usage (“-h” gives human-readable output)
  • du -h — determine how much disk space is being used by current working directory, or any directory you specify after the du command (as in df, the “-h” means human-readable)
  • fdisk -l [/dev/hda] — show partition table(s), leave off device name to list all
  • mount or cat /etc/mtab — show currently mounted file systems.
  • hwinfo –block –short — show what hard drives are available on the system

Local Devices Diagnostic Tools/Utilities

  • dmidecode — get all bios information, e.g. computer type.
  • hwinfo –pci — list devices on the pci bus.
  • hwinfo –scsi — list all scsi devices.
  • hwinfo –usb — list all usb devices.
  • lsdev — list all installed hardware.
  • lspci — list devices on the pci bus.
  • lsscsi — list all scsi devices.
  • lsusb — list all usb devices.
  • setserial -bg /dev/ttyS[0-9]* — list all active serial devices(/dev/ttyS*).

Kernel Utilities

  • lsmod — list kernel modules currently loaded.
  • modprobe is a Linux program originally written by Rusty Russell and used to add a loadable kernel module (LKM) to the Linux kernel or to remove a LKM from the kernel.

Network Diagnostic Tools/Utilities

  • Directory /proc/net/
    • File arp: arp cache. Maps IP address to MAC address
    • File dev: byte and packet statistics on a per device basis.
    • File netstat: various statistics
    • File tcp: established connections.
  • Directory /proc/sys/net/ipv4/
    • File: ip_forward: read/write. Whether or not the kernal will forward IP packets from one interface to another. This is turned on if you want the machine to work as a router or a firewall.
  • ethtool $interface — show the card’s speed, capabilities and if a link is detected
  • hwinfo –netcard — show the module name, driver activation command, network card name etc.
  • ifconfig -a — show all current network interface information
  • ifconfig $interface — show the information for $interface (usually something like ifconfig eth0)
  • ping $host — use ping to determine if $host is alive on the network (for troubleshooting your local machine $host can equal “127.0.0.1” or “localhost
  • route -n — show routing table, using numerical addresses.

X-Windows Troubleshooting Tools/Utilities

  • cat /var/log/XFree86.0.log — print out the XFree86 error log.
    • Note that some systems do not store this log in /var/log. Use either locate XFree86.0.log or find / -name XFree86.0.log to find it.
  • glxinfo — show the status of your OpenGL subsystem.

Conceptual understanding of sysfs, udev, hald, dbus

sysfs is a virtual file system provided by the Linux kernel. By using virtual files, sysfs exports information about various kernel subsystems, hardware devices and associated device drivers from the kernel’s device model to user space.

udev is a device manager for the Linux kernel. As the successor of devfsd and hotplug, udev primarily manages device nodes in the /dev directory.

hald (hald – HAL daemon) is a daemon that maintains a database of the devices connected to the system system in real-time. The daemon connects to the D-Bus system message bus to provide an API that applications can use to discover, monitor and invoke operations on devices.

D-Bus is a message bus system, a simple way for applications to talk to one another. In addition to interprocess communication, D-Bus helps coordinate process lifecycle; it makes it simple and reliable to code a “single instance” application or daemon, and to launch applications and daemons on demand when their services are needed.

LPI-1 Linux Certification – Study Materials

Linux Server Professional Certification Guide

Exam Objectives:
https://www.lpi.org/linux-certifications/programs/lpic-1/exam-101/

https://www.lpi.org/linux-certifications/programs/lpic-1/exam-102/

 

Study Materials:

  1. IBM DeveloperWorks study guide
  2. WikiBooks – LPI Certification Guide
  3. Professor Messer – CompTIA LX0-101 Linux+ and LPIC-1 Training Videos
  4. Cybrary.it Linux+ video training