Skip to content

Linux Kernel

kimschles edited this page Apr 11, 2019 · 3 revisions

How Linux Works

Process Management

  • A process is an instance of a program
  • Starting, stopping, resuming and terminating a process

Memory Managment Device Drivers and Management

Linux Programming Interface

Process Scheduling Memory Management Provision a File System Creation and Termination of Processes Access to Devices Networking Provision a system API

Monitoring Processes

  • init runs shell scripts that live in /etc
  • Those scripts are called init scripts
    • Most of those services as daemon programs that run in the background
  • Parent process vs. child process
  • PID -> process id
    • pids are assigned in ascending order
    • init is always pid 1
  • ps shows the processes associated with the current terminal sesion
    • TTY is teletype
    • TIME the amount of CPU time consumed by a process
  • ps x is a way to see processes no matter which terminal
    • STAT is state
  • ps aux shows processes belonging to every user
  • top is a way to look at processes over time (ps is a snapshot of what is happening in the moment the commandf is run)

Controlling Processes

Interrupting

  • ctcl-C is a 'polite' way to ask the program to stoip

  • To start a process and put it in the backgroup immediately, run the command and add &

    • example: kwrite &
  • jobs shows you jobs that are running

  • fg lets you return a process to the foreground

    • fg %1 kills a job if there is only one running in the background
  • jobspec: %1

Signals

  • kill is used to terminate a process
  • killall

Questions I have:

  • How are UNIX and Linux related?
  • What is a driver?

Chapter 5: How the Linux Kernel Boots

5.1: Startup Messages

  • To see the startup messages, find the kernel system log file.
    • /var/log/kern.log or /var/log/messages
  • the dmesg command

5.2: Kernel Initialization and Boot Options

  • First the kernel boots, then the user space boots

The kernel initializes roughly in this order:

  1. CPU inspection
  2. Memory inspection
  3. Device bus discovery
  4. Device discovery
  5. Auxiliary kernel subsystem setup (networking, and so on)
  6. Root filesystem mount
  7. User space start

From the LinkedIn Linux: Kernels and Logging for System Administration course:

  1. Firmware stage
  2. Boot loader stage
  3. Kernel stage
  4. Initialization stage

5.3: Kernel Parameters

  • kernel parameters are key value pairs like console=tty1 or one-word flags like ro
  • view the kernel parameters at /proc/cmdline
    • example cmdlinecat file: BOOT_IMAGE=/boot/vmlinuz-4.15.0-1032-aws root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295
  • some kernel paramters of note:
    • root specifies the location of the root filesystem
    • ro means read-only

5.4: Boot Loaders

GRUB

# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"```




Clone this wiki locally