Book Image

CompTIA Linux+ Certification Guide

By : Philip Inshanally
Book Image

CompTIA Linux+ Certification Guide

By: Philip Inshanally

Overview of this book

The Linux+ certification provides a broad awareness of Linux operating systems, while giving professionals an upper hand in the IT industry. With this certification, you’ll be equipped with the all-important knowledge of installation, operation, administration, and troubleshooting services. This CompTIA Linux+ Certification Guide will give you an overview of the system architecture. You’ll understand how to install and uninstall Linux distributions, followed by working with various package managers. You’ll then move on to manipulating files and processes at the command-line interface (CLI) and creating, monitoring, killing, restarting, and modifying processes. As you progress, you’ll be equipped to work with display managers and learn how you can create, modify, and remove user accounts and groups, as well as understand how to automate tasks. The last set of chapters will help you configure dates and set up local and remote system logging. In addition to this, you’ll explore different internet protocols, and delve into network configuration, security administration, Shell scripting, and SQL management. By the end of this book, you’ll not only have got to grips with all the modules you need to study for the LX0-103 and LX0-104 certification exams, but you’ll also be able to test your understanding with practice questions and mock exams.
Table of Contents (23 chapters)
19
Mock Exam - 1
20
Mock Exam - 2

Modules

Have you ever wondered what happened to the term drivers in a Linux environment? Well, wonder no more. Most people coming from a Microsoft Windows background are accustomed to interacting with hardware through the use of drivers. In Linux, we refer to drivers as modules. This isn't as scary as it sounds. We load and unload modules whenever we are working with a piece of hardware. For example, when we plug in a USB drive, a module is loaded into the backend and is unloaded automatically when we remove the USB drive. It's that flexible.

Let's take a look at how we can view the modules that are installed in the Linux system using the lsmod command:

More modules that are available for use are shown in the following screenshot:

From the preceding output, we can see that a number of modules are available for use in this Linux system. We read the output from left to right. Wherever we see a 0 value under the Used by column, it means that the module is not currently in use.

Now let's look at the process to remove a module using the rmmod command. We will remove the usbhid module, since it's not currently in use. We can quickly verify this is not in use by using lsmod | grep usbhid:

root@trainer-virtual-machine:~# lsmod | grep usbhid
usbhid 49152 0

Great! Let's go ahead and remove that module using the rmmod command:

root@trainer-virtual-machine:~# rmmod usbhid
root@trainer-virtual-machine:~#
root@trainer-virtual-machine:~# lsmod | grep usbhid
root@trainer-virtual-machine:~#

There we go; the usbhid module is no longer loaded in the Linux system. It still resides there, however, because it was compiled in the kernel. There are only a few options to pass with rmmod. Here, they are on an Ubuntu distro:

Similarly, here are the options to pass with the rmmod on a CentOS 7 distro:

In order for us to reinstall this usbhid module, we will use another popular command: insmod. Let's see how insmod works at the shell:

root@trainer-virtual-machine:~# insmod usbhid
insmod: ERROR: could not load module usbhid: No such file or directory
root@trainer-virtual-machine:~#

Now, based on the preceding output, it may seem to be contradictory that the insmod command is unable to find the usbhid module. Don't worry, this module is compiled in the kernel. That being said, we can use yet another helpful command, modprobe. This, by far, is more popular than insmod, as modprobe actually calls insmod in the backend whenever we add a module using modprobe. Interestingly enough, modprobe can be used to remove module(s) too. It does this by calling rmmod in the backend.

We can use insmod itself to install the usbhid module. The only catch is that you have to specify the absolute path to the module. modprobe, on the other hand, uses the modules directory (namely /lib/modules/$(KERNEL_RELEASE)/) for modules, and loads modules based on the rules defined in the /etc/modprobe.d/ directory.

So, let's use modprobe to install the usbhid module at the shell.

root@trainer-virtual-machine:~# modprobe -v usbhid
insmod /lib/modules/4.4.0-24-generic/kernel/drivers/hid/usbhid/usbhid.ko
root@trainer-virtual-machine:~#

We used the (-v) option with modprobe because, by default, it will not show what is happening in the background. As you can see, modprobe is indeed calling insmod in the backend. Now we can remove this usbhid module using modprobe, and we will see that it is calling rmmod in the backend:

root@trainer-virtual-machine:~# modprobe -r -v usbhid
rmmod usbhid
root@trainer-virtual-machine:~#

From the preceding output, it is evident that modprobe is calling rmmod to remove a module.

Here are some options that can be used with the modprobe command on an Ubuntu distro:

More options that can be passed with the modprobe command are shown in the following screenshot:

Some more options that can be passed with the modprobe command are shown in the following screenshot:

Here are some options that can be used with the modprobe command on a CentOS 7 distro:

Some more options that can be passed with the modprobe command are shown in the following screenshot:

More options that can be passed with the modprobe command are shown in the following screenshot: