The Linux Kernel: Introduction

Discussion in 'Linux Kernel' started by DevynCJohnson, Jul 10, 2013.

  1. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    Index
    NOTE: To better understand this article, check out the previous articles in this series.
    Introduction
    Source Code
    Drivers
    Security
    Configuration Part 1
    Configuration Part 2
    Configuration Part 3
    Configuration Part 4
    Configuration Part 5
    Configuration Part 6
    Configuration Part 7
    Configuration Part 8
    Configuration Part 9
    Configuration Part 10
    Configuration Part 11
    Configuration Part 12
    Configuration Part 13
    Configuration Part 14
    Configuration Part 15
    Configuration Part 16
    Configuration Part 17
    Configuration Part 18
    Configuration Part 19
    Configuration Part 20
    Configuration Part 21
    Configuration Part 22
    Configuration Part 23
    Compiling and Installing
    Modules
    Patches
    Types of Kernels

    List of Kernel Topics on Linux.org


    In 1991, a Finnish student named Linus Benedict Torvalds made the kernel of a now popular operating system. He released Linux version 0.01 on September 1991, and on February 1992, he licensed the kernel under the GPL license. The GNU General Public License (GPL) allows people to use, own, modify, and distribute the source code legally and free of charge. This permits the kernel to become very popular because anyone may download it for free. Now that anyone can make their own kernel, it may be helpful to know how to obtain, edit, configure, compile, and install the Linux kernel.

    A kernel is the core of an operating system. The operating system is all of the programs that manages the hardware and allows users to run applications on a computer. The kernel controls the hardware and applications. Applications do not communicate with the hardware directly, instead they go to the kernel. In summary, software runs on the kernel and the kernel operates the hardware. Without a kernel, a computer is a useless object.

    There are many reasons for a user to want to make their own kernel. Many users may want to make a kernel that only contains the code needed to run on their system. For instance, my kernel contains drivers for FireWire devices, but my computer lacks these ports. When the system boots up, time and RAM space is wasted on drivers for devices that my system does not have installed. If I wanted to streamline my kernel, I could make my own kernel that does not have FireWire drivers. As for another reason, a user may own a device with a special piece of hardware, but the kernel that came with their latest version of Ubuntu lacks the needed driver. This user could download the latest kernel (which is a few versions ahead of Ubuntu's Linux kernels) and make their own kernel that has the needed driver. However, these are two of the most common reasons for users wanting to make their own Linux kernels.

    Before we download a kernel, we should discuss some important definitions and facts. The Linux kernel is a monolithic kernel. This means that the whole operating system is on the RAM reserved as kernel space. To clarify, the kernel is put on the RAM. The space used by the kernel is reserved for the kernel. Only the kernel may use the reserved kernel space. The kernel owns that space on the RAM until the system is shutdown. In contrast to kernel space, there is user space. User space is the space on the RAM that the user's programs own. Applications like web browsers, video games, word processors, media players, the wallpaper, themes, etc. are all on the user space of the RAM. When an application is closed, any program may use the newly freed space. With kernel space, once the RAM space is taken, nothing else can have that space.

    The Linux kernel is also a preemptive multitasking kernel. This means that the kernel will pause some tasks to ensure that every application gets a chance to use the CPU. For instance, if an application is running but is waiting for some data, the kernel will put that application on hold and allow another program to use the newly freed CPU resources until the data arrives. Otherwise, the system would be wasting resources for tasks that are waiting for data or another program to execute. The kernel will force programs to wait for the CPU or stop using the CPU. Applications cannot unpause or use the CPU without the kernel allowing them to do so.

    The Linux kernel makes devices appear as files in the folder /dev. USB ports, for instance, are located in /dev/bus/usb. The hard-drive partitions are seen in /dev/disk/by-label. It is because of this feature that many people say "On Linux, everything is a file.". If a user wanted to access data on their memory card, for example, they cannot access the data through these device files.

    The Linux kernel is portable. Portability is one of the best features that makes Linux popular. Portability is the ability for the kernel to work on a wide variety of processors and systems. Some of the processor types that the kernel supports include Alpha, AMD, ARM, C6X, Intel, x86, Microblaze, MIPS, PowerPC, SPARC, UltraSPARC, etc. This is not a complete list.

    In the boot folder (/boot), users will see a "vmlinux" or a "vmlinuz" file. Both are compiled Linux kernels. The one that ends in a "z" is compressed. The "vm" stands for virtual memory. On systems with SPARC processors, users will see a zImage file instead. A small number of users may find a bzImage file; this is also a compressed Linux kernel. No matter which one a user owns, they are all bootable files that should not be changed unless the user knows what they are doing. Otherwise, their system can be made unbootable - the system will not turn on.

    Source code is the coding of the program. With source code, programmers can make changes to the kernel and see how the kernel works.

    Downloading the Kernel:

    Now, that we understand more about the kernel, it is time to download the source code. Go to kernel.org and click the large download button. Once the download is finished, uncompress the downloaded file.


    For this article, I am using the source code for Linux kernel 3.9.4. All of the instructions in this article series are the same (or nearly the same) for all versions of the kernel.

    In my next article, we will discuss how the source code is arranged.
    Last edited: Dec 29, 2013
  2. larky

    larky New Member

    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    Hi, I cannot see the large download button on the HOME page. Would you please figure out which position does the button display? Many thanks.:)
  3. larky

    larky New Member

    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    And this is what my Home page looks like.

    Attached Files:

    Mitt Green and DevynCJohnson like this.
  4. dSims

    dSims New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I too am having the same problem. is there something I am missing?
  5. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    Nice home page. I am so jealous of you. (^u^)
    That home page beats Google any day of the week.
  6. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    What exactly are you wanting to know?
  7. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    If you are talking about the button for downloading the Linux kernel's source code, read the third last paragraph in my article:

    "Now, that we understand more about the kernel, it is time to download the source code. Go to kernel.org and click the large download button. Once the download is finished, uncompress the downloaded file."

    I hope that is what you are asking.
    nizar likes this.
  8. larky

    larky New Member

    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    Dear DevynC Johnson - Thanks so much. What you explain is exactly what I want.
    DevynCJohnson likes this.
  9. John_Beatty

    John_Beatty New Member

    Messages:
    1
    Likes Received:
    2
    Trophy Points:
    1
    In paragraph 6 above, do you mean: "If a user wanted to access data on their memory card, for example, they cannot could access the data through these device files. ?
    schspa and DevynCJohnson like this.
  10. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    Can you click /dev/sda2 and see the files? No.

    I know what you are saying, but the user themselves cannot get to the files via /dev/*. Good question though.
  11. schspa

    schspa New Member

    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    3
    It helps..thanks..
    DevynCJohnson likes this.
  12. JasonHH

    JasonHH New Member

    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    It's helpful.
    DevynCJohnson likes this.
  13. automate

    automate New Member

    Messages:
    3
    Likes Received:
    2
    Trophy Points:
    3
    Very helpful . I will follow you ... ! come on ! 顶!!!
    DevynCJohnson likes this.
  14. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    Thanks and welcome to Linux.org!
  15. raviteja

    raviteja New Member

    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    3
    very helpful, i did not understand this " If a user wanted to access data on their memory card, for example, they cannot access the data through these device files." U mean this is a restricted area
    DevynCJohnson likes this.
  16. lobo

    lobo Active Member

    Messages:
    134
    Likes Received:
    81
    Trophy Points:
    28
    What Devyn says isn't strictly true, but it's still to all intents and purposes correct in the sense that you cannot access the device file system from e.g. /dev/sda1

    In a GNU/Linux system, or most *nix systems, files in /dev refer to actual devices, not file systems. So to be able to access the files on a block device, you would first need to mount it using the correct fs driver (in most cases mount command will take care of this).

    You can still read and write raw data from /dev/sda1 (potentially destroying data, mbr, partition table - the lot - in the process) using something like dd.
    DevynCJohnson likes this.
  17. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    By that, I mean you cannot click /dev/sda2 to get to your second partition. These are not used like other shortcuts/files.
  18. DevynCJohnson

    DevynCJohnson Super Moderator Staff Member Staff Writer

    Messages:
    980
    Likes Received:
    859
    Trophy Points:
    93
    I like your answer. ;)
  19. Arnel Batino

    Arnel Batino New Member

    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    1
    I'm new in this section and hoping that i would learn a lot about Linux :D
    hope you'll help me with this hehehe Thank you so much!
    DevynCJohnson likes this.
  20. Harikrishnan R

    Harikrishnan R New Member

    Messages:
    29
    Likes Received:
    18
    Trophy Points:
    3
    Thanks a lot. Why don't you remove "NOTE: To better understand this article, check out the previous articles in this series." from this ? :)
    DevynCJohnson likes this.

Share This Page