jump to navigation

Linux : lesson1-2 : The Kernel, Programs, and Processes October 29, 2010

Posted by Tournas Dimitrios in Linux course.

The Linux kernel is an operating system, just as Windows, MacOS, and OS/2 are operating systems. The operating system is an environment in which programs run, providing mechanisms for programs to interact with the computer hardware. The kernel lets programs know when a keyboard key was struck, when the mouse moved, or when a packet destined for the program arrived over the network. The kernel allows programs to access the harddrive, perhaps to read a configuration files or store data.

Just as it would be difficult to explain what a language is to people who have grown up only knowing about one language, it is often difficult to explain what an operating system is to people who are new to computers, or who have only used one operating system. The operating system operates at such a low level, that users don’t interact with it directly, and often don’t realize that the programs they are running are using it.


Programs are files that are stored on a computer’s harddrive. A program is a series of very basic instructions, that tell the operating system what to do and when to do it in a very detailed and specific manner. The following might be the instructions written down in the file /usr/X11R6/bin/xcalc, a common calculator program.

“While the user isn’t doing anything, blink the cursor. When the user hits a key, if it’s a number, write it to the screen. If it’s not a number, ignore it, unless it’s the return key. If it’s the return key, add the previous number to the total, and print the total.”

Of course, the instructions are not written in English, or any other human readable language. Instead, a computer, at the lowest level, only knows how to perform a small number of tasks, say 256 of them. Imagine that each of these tasks were numbered, task number 0 through task number 255. Programs really look more like the following instructions:

“Do task 23. If the result is greater than 0, do task 45. Otherwise, do task number 82. Take the result, and store it into memory.”

Because the tasks that a computer can do vary from one type of CPU to another, and because different operating systems can be thought of as numbering the tasks differently, programs that are compiled for one type of operating system will generally not run on other operating systems.


When a user instructs the kernel to run a program, the kernel reads the instructions found in the program file, and loads them into memory. It then begins performing the instructions. The copy of the program running in memory is called a process. Note that the same program can be loaded into memory and run more than once, so that at any point the kernel might be running several processes of the same program.

Linux, like most modern operating systems, is a multitasking operating system. This means that the kernel gives the appearance of running multiple processes simultaneously. In reality, the kernel is running a single process for a brief amount of time, usually on the order of 50 milliseconds. It then swaps that process out, and swaps in another one for its 50 milliseconds of action. Eventually, the kernel works its way through all of the processes and starts over again. The rapid switching from process to process gives the users of the machine the impression that all of the processes are running simultaneously.


Linux users often use a special type of program, called a shell, to interact with the kernel. The shell runs within a terminal, issuing a prompt and waiting to be told what to do. A user then asks the shell to run a program by typing in the name of the program. In the following example, the user elvis asks the shell to run a simple calendar program called cal. The shell dutifully executes the program, and reports the program’s output back to the terminal:

[elvis@station elvis]$ cal
      May 2003
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

[elvis@station elvis]$

Because users use a shell to perform almost every task on the system, the shell is an important and sophisticated program. Much of this course will be devoted to learning how to use the shell to perform tasks effectively.

When the user asks the shell to run a program, the user is said to be specifying a command for the shell. The shell is often referred to as a Command Line Interface.

The ps command

The ps command is commonly used to list processes running on a system. The ps command, without arguments, shows all of the processes that were started from a single terminal (or terminal window in a graphical environment). In the following example, elvis discovers that his terminal currently has two processes running: his bash shell, and the ps command itself.

[elvis@station elvis]$ ps
  PID TTY          TIME CMD
 1378 pts/1    00:00:00 bash
 1418 pts/1    00:00:00 ps

The first column shows the process’s PID, or Process ID. Every process running on the system is identified by a unique PID. The second column identifies elvis’s terminal, and the third column reports how much CPU time the process has consumed.

The ps aux command shows a detailed list of all processes that are currently running on the system. For now, we will not go into the details of what “aux” stands for, just consider it black magic to be memorized.



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s