The heart of Red Hat is the Linux kernel. The kernel is responsible for interacting with the hardware and producing output to the screen. There is also a virtual file system that gets created in the /proc directory to hold information and parameters for the kernel.
Linux is truly just the kernel. Red Hat and the other distributions in existence today are software and configuration files packaged with the linux kernel to bring you an entire operation system. Because the kernel is really what runs everything, understanding how it works is essential.
The Kernel can be used to load new drivers, support new hardware, or even offer a custom kernel for individual needs.
The Linux Kernel is modular, and because of this, you can load and unload kernel modules even after the system has booted.
Let’s start with the uname command to find out some info, about the kernel.
Uname: Displays information about the Kernel.
Syn: Uname [option]
-a——>prints all information relating to the kernel
-s——>show the kernel name
-r——>requests kernel release information
-v——>requests the kernel version.
——> Let’s check &see which version of the kernel is currently running:
Linux root 126.96.36.199.e16.x86_64…
* Note: The kernel version numbering is important here.
The first number is the major version of the kernel. The second number is the major release of the first number.
If the release number is even, which it is (6), it means that this is a stable release of the kernel. Odd numbers are development kernels and should not be used for production systems.
The third number is the patch version of the kernel.
The last number (710 is added by Red Hat to represent its release version of the kernel. Also note the el6, which tells you that you are running Red Hat Enter price Linux6. If you couldn’t tell, this is an x64 – bit version of the operating system.
- To get the version of the currently installed kernel:
#rpm -qa /grep kernel
- You could also use the following:
#rpm – q kernel
When it comes to working with kernels, you should be familiar with different locations. Let’s look at four of these locations:
/boot : place where the kernel and boot files are kept
/proc : Current hardware configuration & status.
/usr/src : Source code of the kernel.
/lib/modules : Kernel modules.
Lsmod: Lists currently loaded kernel modules
- To look at what is currently loaded by the kernel since you booted the system, you use the following command:
|L2cap||29505||1ʘ hidp, rfcomm|
- The preceding output is truncated due to size.
- Show the details of the ext4 kernel module listed previously:
Modinfo: Displays information about a kernel module
- To find all the kernel Modules:
- All the kernel modules will be residing in /etc/lib/modules directory.
# cd /etc/lid/modules
- To search all the kernel modules in the system using find cmd:
#find / -name *.ko (Modules in the system will b ending with .ok extension)
Mod probe: à To remove the loaded module
Syn: modprobe <modname>
#modprobe –r vfat
- Now to check
#lsmod /grep -i vfat
- To install / re-install a module:
# lsmod / grep – i vfat
* Updating the kernel:
- View the current version of the kernel:
# uname – r
- To view kernel package information
# yum inof kernel
#rpm – qi / grep kernel /
- Using the package manager, you can upgrade the kernel to the latest version:
# yum update kernel – y
# rpm – ivh kernel -2.6.18-194.3.lel5
* Note: when updating a kernel with the rpm command, never use the -U option to update. The reason behind this is that the update option erases the prior kernel when updating, whereas the –i option installs the newer kernel alongside the old kernel. If something doesn’t work or goes wrong, you have an older kernel to revert to.
Desired to gain proficiency on Linux ? Explore the blog post on Linux training online to become a pro in Linux .
Tuning the kernel with /proc/ sys:
The kernel has a virtual file system, / proc/ sys, that allows you to tune the kernel while the system is running.
The kernel creates the / proc / sys virtual file system when the system boots up, which holds all the parameters of the kernel. This virtual file system is them used to manipulate kernel parameters for testing purposes (these changes are valid only until the system reboots).
When you have the kernel tuned the way you’d like, you can simply have your settings applied when the system boots (through a special config file), or you can compile your own kernel to have them built in permanently
As you are testing kernel changes, make sure you don’t rely on any settings made within the / proc / sys file system because they are erased when the system reboots. During testing you can use the echo cmd to change the values of the kernel while the system is running.
Step 1): View the current value in the kernel:
#cat / proc/sys/net/ipv4/ip-forward
Step 2): Change the kernel option that controls packet forwarding:
#echo 1 > /proc/sys/net/ipv4/ip-forward
Step 3): Verify the value has changed:
#cat / proc/sys/net/ipv4/ip –forward
If you want the changes to be persistent across system reboots, you can put the parameters you’d like to remain during boot in the letc/sysctl . conf file.
Sysctl: Enables you to tune kernel
Before you start tuning things, let’s look at all the available options:
Now, let’s make the same changes to the kernel as before.
Step 1) : query the parameter responsible for forwarding packets within the kernel
#sysctl – / grep ip_forward
Step 2): Using sysctl to change the option:
#sysctl -w net.ipv4.ip-forward = 1
Enables you to change a settings in the sysctl config file.
Step 3): verify the value has been changed:
# Sysctl – a / grep ip – forward
Step 4): return the parameter to its original value:
#sysctl -w net.ipv4.ip-forward=ʘ
For indepth understanding of Linux click on