Linux-Kernal Tutorial for Beginners & Experts - A Perfect Guide to Refer In 2020
Linux Kernel Tutorial

Linux-Kernal Tutorial for Beginners & Experts – A Perfect Guide to Refer

Last updated on 07th Jul 2020, Blog, Tutorials

About author

Neel Pratyush (Azure IoT Engineer )

Neel Pratyush is an Azure IoT Engineer with 6 years of experience in Microsoft Azure, IoT, Embedded Systems, and CyberArk. He has expertise in affiliate, pacesetting, authoritative, coercive, and laissez-faire management styles.

(5.0) | 19288 Ratings 1143

Linux was initially developed by Linus Torvalds in 1991 as an operating system for IBM compatible personal computers based on the Intel 80386 microprocessor.

Linus remains :

  • deeply involved with improving Linux, keeping it up-to-date with various hardware
  • developments and coordinating the activity of hundreds of Linux developers around the world.
  • Over the years, developers have worked to make Linux available on other
  • architectures, including Alpha, SPARC, Motorola MC680x0, PowerPC, and IBM System/390.

One of the more appealing benefits to Linux is that it isn’t a commercial operating system: its source code under the GNU Public License[1] is open and available to anyone to study, as we will in this book; if you download the code (the official site is http://www.kernel.org/) or check the sources on a Linux CD, you will be able to explore from top to bottom one of the most successful, modern operating systems. This book, in fact, assumes you have the source code on hand and can apply what we say to your own explorations. 

This is a collection of lectures and labs Linux kernel topics. The lectures focus on theoretical and Linux kernel exploration.The labs focus on device drivers topics and they resemble “howto” style documentation. Each topic has two parts:

  • a walk-through the topic which contains an overview, the main abstractions, simple examples and pointers to APIs
  • a hands-on part which contains a few exercises that should be resolved by the student; to focus on the topic at hand, the student is presented with a starting coding skeleton and with in-depth tips on how to solve the exercises

This content is based on the Operating Systems 2 course from the Computer Science and Engineering Department, the Faculty of Automatic Control and Computers, University POLITEHNICA of Bucharest.

You can get the latest version at http://github.com/linux-kernel-labs.

To get started building the documentation from the sources after installing docker-compose on your host:

  • cd tools/labs && make docker-docs
  • then point your browser at Documentation/output/labs/index.html.

Alternatively, you can build directly on the host (see tools/labs/docs/Dockerfile for dependencies):

Basic Features

The following are some of the important features of the Linux Operating System.

    Subscribe For Free Demo

    [custom_views_post_title]

    • Portable : Portability means software can works on different types of hardware in the same way. Linux kernel and application programs support their installation on any kind of hardware platform.
    • Open Source : Linux source code is freely available and it is a community-based development project. Multiple teams work in collaboration to enhance the capability of the Linux operating system and it is continuously evolving.
    • Multi-User : Linux is a multiuser system that means multiple users can access system resources like memory/ ram/ application programs at the same time.
    • Multi programming : Linux is a multi programming system that means multiple applications can run at the same time.
    • Hierarchical File System : Linux provides a standard file structure in which system files/ user files are arranged.
    • Shell : Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs. etc.
    • Security : Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.
    Install Linux Kernel The procedure to build (compile) and install the latest Linux kernel from source is as follows:
    • Grab the latest kernel from kernel.org
    • Verify kernel
    • Untar the kernel tarball
    • Copy existing Linux kernel config file
    • Compile and build Linux kernel 5.6.9
    • Install Linux kernel and modules (drivers)
    • Update Grub configuration
    • Reboot the system

    INSTALLATION

    Step 1. Get the latest Linux kernel source code

    Visit the official project site and download the latest source code. Click on the big yellow button that read as “Latest Stable Kernel“:

    Course Curriculum

    UPGRADE Your Career with Linux Kernel Training By Highly Experienced Faculty

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum
    Linux-Kernel-Achives

    The filename would be Linux-x.y.z.tar.xz, where x.y.z is the actual Linux kernel version number. For example file Linux-5.6.9.tar.xz represents Linux kernel version 5.6.9. Use the widget command to download Linux kernel source code:

    • $ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.9.tar.xz
    kernel-linux-navigate-bar
    Step 2. Extract tar.xz file

    You really don’t have to extract the source code in /usr/src. You can extract the source code in your $HOME directory or any other directory using the following Unix command or xz command:

    • $ unxz -v linux-5.6.9.tar.xz

    OR

    • $ xz -d -v linux-5.6.9.tar.xz
    Verify Linux kernel tarball with PGP

    First, grab the PGP signature for Linux-5.6.9.tar:

    $ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.9.tar.sign

    Try to verify it:

    $ gpg –verify Linux-5.6.9.tar.sign

    Sample outputs:

    gpg: assuming signed data in ‘linux-5.6.9.tar’

    gpg: Signature made Sun 12 Aug 2018 04:00:28 PM CDT

    gpg: using RSA key 79BE3E4300411886

    gpg: Can’t check signature: No public key

    Grab the public key from the PGP keyserver in order to verify the signature i.e. RSA key ID 79BE3E4300411886 (from the above outputs):

    $ gpg –recv-keys 79BE3E4300411886

    Sample outputs:

    gpg: key 79BE3E4300411886: 7 duplicate signatures removed gpg: key 79BE3E4300411886: 172 signatures not checked due to missing keys gpg: /home/vivek/.gnupg/trustdb. gpg: trustdb created gpg: key 79BE3E4300411886: public key “Linus Torvalds <torvalds@kernel.org>” imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg:imported: 1

    Now verify gpg key again with the gpg command:

    $ gpg –verify Linux-5.6.9.tar.sign

    Sample outputs:

    gpg:assuming signed data in ‘Linux-5.6.9.tar’ gpg: Signature made Sun 12 Aug 2018 04:00:28 PM CDT gpg:using RSA key 79BE3E4300411886 gpg: Good signature from “Linus Torvalds <torvalds@kernel.org>”[unknown] gpg: & aka “Linus Torvalds <torvalds@linux-foundation.org>”[unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: ABAF 11C6 5A29 70B1 30AB E3C4 79BE 3E43 0041 1886

    If you do not get “BAD signature” output from the “gpg –verify” command, untar/extract the Linux kernel tarball using the tar command, enter:

    Course Curriculum

    Learn Linux Kernel Courses to Advance Your Skills & Career

    Weekday / Weekend BatchesSee Batch Details

    $ tar xvf Linux-5.6.9.tar

    Step 3. Configure the Linux kernel features and modules

    Before start building the kernel, one must configure Linux kernel features. You must also specify which kernel modules (drivers) needed for your system. The task can be overwhelming for a new user. I suggest that you copy the existing config file using the cp
    command:

    • $ cd Linux-5.6.9
    • $ cp -v /boot/config-$(namer) .config

    Sample outputs:

    ‘/boot/config-4.15.0-30-generic’ -> ‘.config’

    Step 4. Install the required compilers and other tools

    You must have development tools such as GCC compilers and related tools installed to compile teh Linux kernel.

    How to install GCC and development tools on a Debian/Ubuntu Linux

    Type the following apt command or apt-get command to install the same:

    $ Sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev

    How to build and install the latest Linux kernel from source code

    You have compiled a Linux kernel. The process takes some time, however now you have a custom Linux kernel for your system. Let us reboot the system.

    Reboot Linux computer and boot into your new kernel

    Just issue the reboot command or shutdown command:

    • # reboot

    Verify new Linux kernel version after reboot:

    $ name -Mrs

    Sample outputs:

    Linux Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    Linux 5.6.9 x86_64

    Conclusion

    You completed various steps to build the Linux kernel from source code and compiled kernel should be running on your system. 

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free