Linux Kernel and Processes

  • The Linux kernel is the heart of the Linux system.
  • The kernel is the first part of the OS to load into memory.  It is then used as a intermediary between the computer hardware, the programs running, and the user’s interaction through those programs.
  • The kernel performs tasks in a separate memory location from user’s programs that are run.  Because of its intimate interaction with computer hardware, it is important to keep it running and protect that interaction to ensure stability.
  • Common kernel responsibilities are scheduler, supervisor, interrupt handler, and memory manager.
  • Although you can’t manage the kernel processes the same way as other processes on your system, you can use a series of commands to see which processes are running.  Further processes can be manipulated through other commands shown here:
  • uname — learn about the kernel processes
    • [ -n ] displays the system’s node name (host name)
    • [ -s ] displays the kernel’s name
    • [ -v ] displays the kernel’s version (normally date/time of the build, not actual version)
    • [ -r ] displays the actual kernel version or release
    • [ -m ] displays info about the machine (CPU code i686 or x86_64)
    • [ -p ] displays information about the CPU
    • [ -i ] displays platform information
    • [ -o ] displays the OS name
    • [ -a ] displays all available information
  • ps — a tool for process management (aka:  Process Status)
    • [ –help ] summarizes common ‘ps’ commands
    • [ -A ] displays processes that were run from its own terminal
    • [ -u + user ] displays processes run by a given user (can use the user name or UID)
    • [ -f, -l (el), -j, -I, -u, -v ] displays expanded information about a process
    • [ -H, -f ] displays the hierarchy information and relationships between processes
    • [ -w ] displays the information without the limit of 80 characters wide (used for piping to file)
    • COMMON OUTPUTS:  USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME, COMMAND
  • top — displays running processes (discover which processes are consuming the most CPU)
    • [ -d ] specified a delay between updates
    • [ -p + PID ] monitor a specific process (obtain PID through he ‘ps’ command)
    • [ -n + iterations ] only displays a certain number of updated, then quits
    • [ -b ] batch mode which allows you to enter single letter commands
      • SINGLE LETTER COMMANDS:
      • [ h ] help information
      • [ k ] kill a process (will ask for PID)
      • [ q ] quits the single option batch mode
      • [ r ] change a process’ priority (negative values increase priority)
      • [ s ] changes the display update rate (entered in seconds)
      • [ P ] sets the display to sort by CPU
      • [ M ] sort by memory usage
  • jobs — displays minimal information about the processes associated with the current session
    • jobs are numbered from 1 and up, and are displayed instead of the PID (this can be useful)
    • can be used to check to make sure that processes were killed prior to log off
  • fg — known as foreground.  Get back to your command line while still leaving the process running
    • [ Ctrl+Z ] will take you out of your program
    • [ fg ] will get you back into the program that you sent to the foreground
    • for several processes sent to the foreground, use the job number to specify (‘fg 2’)
    • use the ‘jobs’ command to find out the job number of the one you want to restore
  • bg — similar to foreground, except that it restores a process to the background (no interaction needed)
    • used to send CPU intensive tasks to the background; ones that don’t need interaction
    • [ Ctrl+Z ] will take you out of the program (will usually freeze the program)
    • [ bg ] will send the process to the background
    • can append a command with the [ & ] to send it automatically to the background
  • nice — will re-prioritize a process as you launch it
    • the range of values are -20 to 19 (negative numbers are a higher priority)
    • launch the program using the nice command
    • example :  ‘nice -20 program1’
    • only root may give a program a higher priority, but anyone can make a priority greater
  • renice — does the same thing as ice, but does it by reprioritizing without shutting down the program
  • kill — terminates a process
    • [ -l (el) ] list numbered signals associated with specific names
    • [ -s + signal ] sends the specified signal to the process
      • signal 1 — SIGHUP terminates interactive programs and causes daemons to reread the config files
      • signal 9 — SIGKILL causes the process to exit without performing routine shutdown tasks
      • signal 15 — SIGTERM causes the process to exit, but allows it to close open files (default signal)
      • enter the PID after the signal to terminate that process
  • killall — terminates a program based on its name instead of the PID
    • [ -s + signal ] to specify the type of kill
    • [ -i ] will list processes to kill.  Commonly used if you are root to avoid killing processes that you shouldn’t kill
Scroll to top