Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
CompTIA Linux+ Certification Guide
CompTIA Linux+ Certification Guide

CompTIA Linux+ Certification Guide: A comprehensive guide to achieving LX0-103 and LX0-104 certifications with mock exams

By Philip Inshanally
$35.99 $24.99
Book Sep 2018 590 pages 1st Edition
eBook
$35.99 $24.99
Print
$43.99
Subscription
$15.99 Monthly
eBook
$35.99 $24.99
Print
$43.99
Subscription
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 26, 2018
Length 590 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789344493
Vendor :
CompTIA
Table of content icon View table of contents Preview book icon Preview Book

CompTIA Linux+ Certification Guide

Configuring the Hardware Settings

This chapter covers viewing interrupts. It focuses on /proc/interrupts, CPU info viewing (/proc/cpuinfo), and viewing the physical memory installed. It also looks at /proc/meminfo, the free command, viewing swap memory, and adding and removing additional swap memory using the dd, mkswap, swapon, and swapoff commands. The raid status (viewing/proc/mdstat) is outlined, as is the /dev devices directory, the /proc virtual directory, the lsmod command and its usage, the modprobe command and its usage, and the lspci command and its usage. The /proc directory is a virtual filesystem that is created upon boot up, which stores various items of hardware information about a system.

Navigating through the various directories and using these commands is very informative, and allows you to retrieve hardware information in a Linux environment.

We will cover the following topics in this chapter:

  • Viewing CPU, RAM, and swap info
  • Interrupts and devices
  • Modules

Viewing CPU, RAM, and swap info

Let's take a look at how we can view CPU, RAM, and swap info on a Linux system.

First, we will focus our attention on gaining information on a CPU, so we will look at the /proc/cpuinfo file. We can garner detailed information about the CPU, ranging from the vendor ID, the CPU family, the model name, the CPU rate in MHZ, its cache size, and the number of cores, to name a few. Here is an excerpt from running the cat command alongside /proc/cpuinfo:

Some more information is given here about the CPU:

From the preceding output, we can see detailed information pertaining to the CPU that we ran the cat /proc/cpuinfo command against.

Next, let's take a look at how we can gather information on the amount of physical memory, the Random Access Memory (RAM), installed in a system. We will focus on two commands: the cat /proc/meminfo and the free commands.

Using the Linux system for demonstration once again, we will look at the output of the cat /proc/meminfo command:

Some more memory usage information is shown in the following screenshot:

From the preceding output, we can see some important fields, namely the first three fields (MemTotal, MemFree, and MemAvailable), which reflect the current status of our physical memory (RAM).

Now let's look at another command, the free command. This command will give us the memory information in a more human-readable format. Using our test Linux system, we will run the free command:

Running the free command on its own yields the preceding results in kilobytes. We can tag some options onto the free command to be even more explicit. Here is a list of options that we can use with the free command, using an Ubuntu distro:

These are some more options that we can pass with the free command on an Ubuntu distro:

Similarly, if we take a look at the main page of the free command on a CentOS 7 distribution, we can see similar options:

Some more options that we can pass with the free command on a CentOS 7 distro are shown in the following screenshot:

Let's try a few of the options with the free command:

The preceding output is by far one of the most commonly used options (-h) with the free command. We can even take it a step further by tagging on the (-g) option to display the total amount of physical memory in gigabytes:

We can even see the low and high memory statistics by using yet another fantastic option, the (-l) option:

In the preceding screenshot, we are not just shown the RAM information, but also our swap memory. This is displayed in the last row. We can use another command if we prefer to see only the swap memory. Here, we can use the swapon command:

Here are some options that can be used with the swapon command from the main page of swapon on an Ubuntu distro:

Some more options that can be passed with the swapon command on an Ubuntu distro are shown in the following screenshot:

Here are some options that can be used with the swapon command from the main page of swapon on a CentOS 7 distro:

Some more options that can be passed with the swapon command on a CentOS 7 distro are shown in the following screenshot:

We can also see swap information from within the /proc directory, specifically in /proc/swaps:

From the preceding output, we can see that the swap space is using the /dev/sda4 partition. Now, if for some reason we run out of physical memory and we have maxed out our swap space, then we can either add more physical memory or add more swap space. So, let's focus on the steps to add more swap space.

We will need to create a blank file using the dd command. Note that you need root access to run this command at the shell:

trainer@trainer-virtual-machine:~$ dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
dd: failed to open '/root/myswapfile': Permission denied
trainer@trainer-virtual-machine:~$

From the preceding output, we can see that we got a Permission denied message, so let's switch to the root and try to rerun that command:

root@trainer-virtual-machine:/home/trainer# dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 17.0137 s, 63.1 MB/s
root@trainer-virtual-machine:/home/trainer#

There we go; we've just created a swap file using the name myswapfile. Now we need to run the mkswap command and call the swap file that we just created at the shell:

root@trainer-virtual-machine:~# mkswap myswapfile
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=e3b8cc8f-ad94-4df9-8608-c9679e6946bb
root@trainer-virtual-machine:~#

Now, the last step is to turn on the swap file so that the system uses it as needed:

root@trainer-virtual-machine:~# swapon myswapfile
swapon: /root/myswapfile: insecure permissions 0644, 0600 suggested.
root@trainer-virtual-machine:~#

We've got that warning message telling us about insecure permissions. We will discuss permissions in a later chapter. For now, we will continue to use the existing permissions. The last step is to verify that the swap file is indeed available to our system:

root@trainer-virtual-machine:~# swapon
NAME TYPE SIZE USED PRIO
/dev/sda4 partition 5.9G 960K -1
/root/myswapfile file 1024M 0B -2
root@trainer-virtual-machine:~#

And, voila, we now have the newly created swap file at our system's disposal. We can also run the free command, and we will now find that the swap memory has increased by one gigabyte:

root@trainer-virtual-machine:~# free -h
total used free shared buff/cache available
Mem: 1.9G 848M 72M 13M 1.0G 924M
Swap: 6.8G 960K 6.8G
root@trainer-virtual-machine:~#
In order for the changes to be safe upon reboot, you will need to add an entry in /etc/fstab.

Should we no longer want to use a swap file, we can use the swapoff command to remove myswapfile from the swap memory. Here is how we would accomplish this at the shell:

root@trainer-virtual-machine:~# swapoff myswapfile
root@trainer-virtual-machine:~#

Now let's rerun the swapon command followed by the free command to verify that myswapfile is indeed removed from swap usage:

root@trainer-virtual-machine:~# swapon
NAME TYPE SIZE USED PRIO
/dev/sda4 partition 5.9G 1.6M -1
root@trainer-virtual-machine:~# free -h
total used free shared buff/cache available
Mem: 1.9G 931M 133M 17M 917M 845M
Swap: 5.8G 1.6M 5.8G
root@trainer-virtual-machine:~#

As we can see, myswapfile is no longer available for use as swap memory. Here are the options we can use with the swapoff command on an Ubuntu distro:

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

Here are the options we can use with the swapoff command on a CentOS 7 distro:

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

Interrupts and devices

Now let's switch gears and look at the Interrupt Requests (IRQs) and devices that are available in our Linux system. You can think of an interrupt as a service hotline that we would use whenever we need a particular item. We would ring a service hotline. The theory remains the same for devices within a Linux system; whenever it requires the CPU's attention, it sends out signals via interrupts. Traditional 32-bit architectures support up to 16 interrupts (0-15, as shown in the following screenshot). Newer architectures support far more than 16 interrupts.

Let's take a look at the /proc directory once again, honing in on /proc/interrupts:

More interrupts are shown in the following screenshot:

Some more interrupts are shown in the following screenshot:

From the preceding output, we can see that there are far more interrupts available. The output is read from left to right, where left represents the interrupt number, and moving to the right indicates the devices or services that are using the interrupts. We can see that the timer is using interrupt 0.

Now, let's turn our attention to devices. When we work with devices in a Linux system, the devices are represented by files. This enables us to communicate with the actual hardware in the system. There are some commonly used devices, such as hard disks, DVDs, and USBs, to name a few. Hard disks are represented as sd(n). For example: /dev/sda, /dev/sdb, /dev/sdc, and so on. Hard disk partitions are represented in the form of sd(n). For example: /dev/sda1, /dev/sda2, /dev/sdb1, and so on. Similarly, floppy disks are represented as fd. There are some special use-case files, such as /dev/null, /dev/zero, and /dev/tty*. You would use /dev/null when you want to send output from another command and the output is not needed. This is known as redirecting. /dev/zero is used in conjunction with the dd command that we covered earlier for creating blank files. /dev/tty* is used for remote logins. Let's take a look at how devices are shown in the Linux environment.

We will take a look at /proc/devices using our test Linux system:

From the preceding output, the hard disk and partition are represented in the format of /dev/sdXY, where X represents the hard disk and Y represents the partition. We can tell the ls command to filter the output to only the hard disk and partition information as follows:

root@trainer-virtual-machine:~# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4
root@trainer-virtual-machine:~#

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:

Summary

In this chapter, we focused on hardware settings, looking at the CPU, RAM, and swap information in the various directories. We used a variety of commands. Also, we touched on IRQs and the various interrupts available in a Linux system. We then looked at devices, in the context of files. Finally, we worked with modules. We saw the various modules currently available in a Linux system, and learned the steps to install and remove a module.

In the next chapter, we will focus on the process of booting the system. Moreover, the various boot managers will be covered. This is another critical aspect for every Linux engineer to get to grips with. Simply put, without a boot manager, the system won't be able to boot unless we boot off some form of media. Gaining the knowledge will put you, as a Linux engineer, ahead of other so-called engineers. You will be at a greater advantage regarding certification after completing the next chapter.

Questions

  1. Which directory is created as a virtual file system?

A. /dev
B. /lib
C. /proc
D. None of the above

  1. What is the command to view the CPU info?

A. less /proc
B. more /proc
C. cat /proc
D. cat /proc/cpuinfo

  1. What is the command to view the RAM inside the /proc directory?

A. tail /proc/free
B. less /proc/free
C. cat /proc/meminfo
D. cat /proc/RAM

  1. Which option is used with the free command to display the memory info in a friendly format?

A. free -F
B. free -L
C. free -h
D. free –free

  1. Which command is used to tell the system that a file is a swap file?

A. doswap
B. format swap
C. mkswap
D. swap

  1. Which command is used to activate a swap file?

A. Swap
B. onSwap
C. swap
D. swapon

  1. Which command is used to display the swap-partition info?

A. mkswap
B. swapon
C. swap
D. swapoff

  1. Which device file can redirect messages to be sent for discard?

A. /dev/discard
B. /dev/null
C. /dev/redirect
D. None of the above

  1. Which command is used to display the currently available modules in a Linux system?

A. insmod
B. depmod
C. rmmod
D. lsmod

  1. Which command is used to install a module without having to specify the absolute path?

A. rmmod
B. modules
C. modrm
D. modprobe

Further reading

  • This website will give you all of the necessary information about the current CompTIA Linux+ certification: https://www.comptia.org/
  • This website will give you details relating to LPI exams, specifically the LPIC-1 that you earn by passing both CompTIA Linux+ exams: http://www.lpi.org/
  • This last website gives you details about the various Linux kernels available: https://www.kernel.org/
Left arrow icon Right arrow icon

Key benefits

  • Get a clear understanding of how to achieve Linux+ certification
  • Explore system architecture, Shell scripts, data management, and Linux security
  • Work through practice and mock tests to pass both LX0-103 and LX0-104 exams

Description

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.

What you will learn

Understand the Linux system architecture Install, upgrade, and manage Linux system packages Configure devices and maintain the Linux filesystem Learn to write Shell scripts and manage data Set user interfaces and desktops in the Linux operating system Automate system admin tasks and manage essential system services Manage SQL server on Linux and log locally and remotely with rsyslogd Administer network and local security

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 26, 2018
Length 590 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789344493
Vendor :
CompTIA

Table of Contents

23 Chapters
Preface Chevron down icon Chevron up icon
1. Configuring the Hardware Settings Chevron down icon Chevron up icon
2. Booting the System Chevron down icon Chevron up icon
3. Changing Runlevels and Boot Targets Chevron down icon Chevron up icon
4. Designing a Hard Disk Layout Chevron down icon Chevron up icon
5. Installing a Linux Distribution Chevron down icon Chevron up icon
6. Using Debian Package Management Chevron down icon Chevron up icon
7. Using YUM Package Management Chevron down icon Chevron up icon
8. Performing File Management Chevron down icon Chevron up icon
9. Creating, Monitoring, Killing, and Restarting Processes Chevron down icon Chevron up icon
10. Modifying Process Execution Chevron down icon Chevron up icon
11. Display Managers Chevron down icon Chevron up icon
12. Managing User and Group Accounts Chevron down icon Chevron up icon
13. Automating Tasks Chevron down icon Chevron up icon
14. Maintaining System Time and Logging Chevron down icon Chevron up icon
15. Fundamentals of Internet Protocol Chevron down icon Chevron up icon
16. Network Configuration and Troubleshooting Chevron down icon Chevron up icon
17. Performing Administrative Security Tasks Chevron down icon Chevron up icon
18. Shell Scripting and SQL Data Management Chevron down icon Chevron up icon
19. Mock Exam - 1 Chevron down icon Chevron up icon
20. Mock Exam - 2 Chevron down icon Chevron up icon
21. Assessment Chevron down icon Chevron up icon
22. Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.