by March 15, 2002 0 comments



Linux geeks like to show off their geekiness by talking of recompiling the kernel. 

In most cases, when you use Linux on standard/popular hardware devices, there is no need to go through this step. But still, if you want to give a superior smile the next time the neighborhood geek starts off, here is what it means. 

What is the kernel? It’s the core OS. The Linux kernel contains large chucks of C and assembly code for providing the functions of an OS. Compilation is the conversion of a program written in a programming language (like C, C++, Java, C#) to a binary form that can be understood by a computer. 

Thus, recompiling the kernel means recompiling the original programming code for the kernel. Now, why would you do that? To understand the need for kernel compilation, let’s take a simple program as below.

void main( )
{
printf(“Hello World”);
/* printf(“How are you”); */
}

The DOS prompt in Linux

The Linux command line (also called Linux console) is the equivalent of the MS DOS mode of Windows, where you can issue Linux commands. There are two ways to use the Linux command line. One is through launching a terminal emulator window from the KDE by clicking on its icon on the K Panel (taskbar). This is similar to MS DOS Prompt or Command Prompt in Windows. This will open a window within the KDE desktop where you can type Linux commands like ls (dir), cp (copy) and rm (del). 
The second way is to get into a full Linux command line mode (similar to the option Restart the computer in MS DOS mode). This can be done by pressing CTRL+ALT+F2, CTRL+ALT+F3 or CTRL+ALT+F4. Each key combination will open a new Linux console, hence you can work on three such consoles simultaneously. You will be prompted for your username and password. Once logged in (say as root), you will be shown a prompt as:
[root@shekhar /root]
This prompt is in the form:
[<username>@<hostname> <directory>]
By default you are in your home directory. Hence when logged in as root, you are dropped into /root directory. 

This program simply prints Hello World on the screen. It will not print ‘How are you’ because this line is commented out (enclosed within /* and */). Similarly, the Linux kernel has support for many dozens of hardware, protocols etc. But by default only selected ones (the standard/popular ones) are activated. Support for others are disabled (commented out).

Now if you want your program to display ‘How are you’ also, then you need to uncomment the second line by removing the /* and */ from the source code and compile the program once again. Similarly, you can enable disabled facilities in the Linux kernel, and to do that you have to recompile the kernel and activate it to enable the changes. 

But what if you want to do something totally new, like printing ‘Having fun’? Then you have to write a new program for it and compile it. Similary, for an altogether new functionality, say USB 3 or the latest webcam, you need to download and compile the latest kernel program (called kernel sources), which have support 
for it.

But do you always have to go through the hassles of compiling a new kernel every time you want to add a new device? Not so. The latest Linux kernels are modularized. That is, you can extend their functionality (like supported new devices) by adding small chunks of programs called modules. This is very similar to device drivers in the Windows. 

Again, a module may need to be compiled if it has not already been done by someone else, like the vendor of the product. Subsequently, a module when loaded into memory (similar to
Windows device driver installation) extends the kernel’s functionality. 

Shekhar Govindarajan

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

Your data will be safe!Your e-mail address will not be published. Also other data will not be shared with third person.