3 Common Linux Troubleshooting Techniques for Diagnostics
| technology | system admin - Graeme Messina

3 Common Linux Troubleshooting Techniques for Diagnostics

Linux is a rock-solid operating system. That's why most of the cloud infrastructure that runs online uses Linux to help keep things running smoothly. As solid as the operating system may be, there are times when problems crop up.

If you are new to Linux then you are probably enjoying the fun, responsiveness, and availability of the operating system and its hundreds of distro variants. Things can go wrong when system components don’t work as we expect.

In this post, we look at some common troubleshooting techniques and diagnostic applications to keep things sailing smoothly as they relate to the CompTIA Linux+ certification.

How to Troubleshoot Linux Issues

Linux has excellent diagnostic tools built right into it. On the network front, you can troubleshoot both remote and local connectivity problems right from the terminal by using text commands.

Alternatively, you can use a plethora of graphical applications to track down issues with your network and get them resolved. The same is true for restoring a Linux server back to use by using tools to repair the boot functionality.

3 Linux Tools for Network Troubleshooting

We want to look at some basic network commands that you must understand in order to write the Linux+ exam. They are ping, ifconfig, and tracert. These are fundamental troubleshooting tools that will help you find issues on a network.

ping

Any basic network troubleshooting starts with the ping command, no matter which operating system or platform you use. To use it in Linux, simply drop into a terminal and run the command with a target IP address. Below is an example of how to use the command if our target IP address is 192.168.1.1.

ping 192.168.1.1

Ping in Linux runs indefinitely, so you have to CTRL+C to stop the command. If you would like ping to act more like it does in the Windows operating system then you can run it like this:

ping -c 4 192.168.1.1

Running it with a -c switch enables the routing compartment identifier, while the 4 tells ping to run four times before stopping.

If you find that your network is unreachable, and that your computer/server is also unreachable to the rest of the network, then you might be dealing with a local network issue.

ifconfig

If you are certain that your network cable is connected, and that you have a physical connection to your network switch or router, then you can proceed to checking out the system configuration of your local device. Luckily there is an easy way to do this from the command line in Linux. All we need to do is drop into the terminal and type in the following:

ifconfig

You will get an output that highlights all of your active network connections. If you are using a wired connection then you should see an eth0 or eth1 depending on your setup and how many network cards you have. If you are using a wireless card, then you can look for wlan0 as your wireless adapter. In our example we are looking at eth0, and our IP address is 192.168.1.111. We have removed the mac address from this output, but you can find yours by using this command.

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.1.111  netmask 255.255.255.0  broadcast 192.168.1.255
       inet6 fe80::3eb7:dd41:2b6d:1e28  prefixlen 64  scopeid 0x20<link>
       ether ############ txqueuelen 1000  (Ethernet)
       RX packets 6163515  bytes 6369685703 (5.9 GiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 2803165  bytes 438330018 (418.0 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

traceroute

If you have a connection to your router, but you can't seem to connect to the internet, or to another target computer on another segment of your network, then you can use the traceroute command. A common technique when troubleshooting internet issues is to try and contact a Google DNS server. This is because Google has incredible uptime, so the chances of this target being offline is very, very slim. From the terminal, type the following:

traceroute 8.8.8.8

You will get an output that shows all of the different hops that your data is taking to get onto the internet. If your connection is being blocked, or if it is failing on its way to the target, then you will see which device is causing the issue.

Linux Boot Issue Troubleshooting: An Example

Not all Linux boot issues are catastrophic, which is a good thing! Sometimes you may want to find out what an error message is pointing to, or why a service is failing on boot. Anything that makes the system run less than optimal.

In most cases you will be able to find some great information about your system by looking at the boot.log file on your computer or server. Some of these files require root access, so you may need to run the sudo command in front of these examples. And know what your root password is. If you do not have access to a graphical desktop then you can easily read the contents of your file by simply typing the following from a command line:

cat /var/log/boot.log

This will output the contents of the log file by using the concatenate command (cat). If you wanted to see only the newest or the oldest contents of the file quickly then you could type either of the following:

head /var/log/boot.log

Head for the first 10 lines of the file

tail /var/log/boot.log

Tail for the last 10 lines of the file

The same goes for the /var/log/messages file as well, as it can contain helpful messages about why your system is experiencing boot issues. If your system is running a later version of Linux and you are able to get to a command line, then you can run the command journalctl.

journalctl

Running this command will give you an output from the SystemD logs, and it can help you to pinpoint the exact issue that is plaguing your system.

One of the advantages of Linux for administrators is the fact that it stores so much information about the current state of the machine that it is running on. This is very valuable when you run into boot issues that are preventing the system from booting up.

Even better is the fact that most of the log files are stored as plain text, so even if you are unable to boot the system up into a shell environment then you will still be able to do some investigative digging on the system.

Linux File System Troubleshooting: An Example

Sometimes you might experience a hard disk failure while using your Linux machine. This is terrifying enough on most systems, but in Linux the perception is that it can be especially tough to deal with. However this is not the case, as there are a lot of different tools that we can use to chase down the culprit and allow us to attempt file repairs and configuration changes to non-working storage volumes.

The most commonly used file repair tool for hard drive issues is fsck.(File System ChecK) With this tool you can run file integrity checks, health checks and many other useful features. If you have a hard drive that you wish to scan with fsck then you will need to identify its mount point. To do this, we will use the df command:

df -h

This command will output the current mount points of your system in a human-readable format. Here is an example of the output:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.8G     0  3.8G   0% /dev
tmpfs           784M   29M  755M   4% /run
/dev/sda1       218G   56G  151G  27% /

From this output, you can see that the primary drive (/dev/sda1) is mounted as the root drive (/). If you wanted more information about the hard drive, you can use the parted utility to view the partitions on it with the following:

parted /dev/sda1 'print'

Which outputs the following for my system:

Model: Unknown (unknown)
Disk /dev/sda1: 238GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number  Start  End    Size   File system  Flags
1      0.00B  238GB  238GB  ext4

From this output, you can tell which number the hard drive is listed as, how much free space it has, and the format that the drive has been set up with. All of this information can help to identify problematic drives when you are having issues with your file system.

Final Thoughts

As we have seen there are plenty of great troubleshooting tools available in Linux, but this is merely scratching the surface in terms of what can be done with this operating system. The fact that Linux is free to use is just the cherry on top.

If you are preparing to take CompTIA's Linux+ certification exam then there are plenty of practical lessons that you can learn from playing with the command line terminal. Don't pass on the opportunity to get that hands-on, practical experience!

Download

Download

Ultimate Networking Cert Guide

A 97-page guide to every Cisco, Juniper, F5, and NetApp certification, and how they fit into your career.

By submitting this form you agree that you have read, understood, and are able to consent to our privacy policy.

LEARNING ON MOBILE

Learn anytime anywhere with our mobile apps.

I have read and understood the privacy policy and am able to consent to it.

© 2021 CBT Nuggets. All rights reserved. Terms | Privacy Policy | Accessibility | Sitemap | 1550 Valley River Drive, Eugene, OR 97401 | 541-284-5522
CBT Nuggets