tech fixing a laptop - Thomas Dumortier / Unsplash

10 Essential Linux Commands for Troubleshooting Issues

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

Linux is a great OS if you want full control over your computer. But if you’re new to Linux, figuring out how to fix issues isn’t the same as what you might be used to on other platforms. In this post, I’ll share my favorite Linux commands for troubleshooting.

The best Linux commands for troubleshooting involve managing system resources, network configuration, file permissions, log files, services, and system hardware.

We’ll start with the easier commands and move on to more advanced ones as we go down the list. Read on to see how many you already know, and perhaps discover new tricks you can add to your toolkit.

If you need help with Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your system. Click here to get it for free!

df – View Disk Space

Sometimes I have a large package to install, and I need a quick glimpse of how much disk space I’ve got left.

The df command stands for “disk free” and lists the disk space remaining.
With the right flags, it will give this info to you in a human-readable format:
df -h

df -h to see free space

Other related commands that are useful include lsblk to see an overview of your drives (for example, so you can mount USB drives), and fdisk to modify their partitions.

Related: How to Manage Disk Space on Linux Like a Pro

htop – Monitor System Resources

If my system is running slow for some reason or if a program has hung, I want to find out what’s causing it. If I’m on a desktop environment like Mint or XFCE, I’ll probably pull up its graphical task manager. But what if I only have the command line?

The htop command is a system monitor that lists running processes and resource usage:
htop

htop command on linux
(Press Q to quit htop.)

The htop command aggregates all the info you might get from other commands like free, ps, and top—except it’s given in a more user-friendly format and updates live. So if a program is misbehaving, you can use htop to determine its process ID (PID) and issue a kill command to stop it.

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In

On some distributions, you may need to use the package manager to install it if it’s not available right away, for example:
sudo apt install htop

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

Tip: Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them. You can grab the PDF here if you want to save some time.

ping – Test Network Connectivity

I can’t count how many times I’ve needed to figure out whether the internet is working properly or whether one of my machines is connectable.

The ping command sends a request to a specific IP address to test if it’s reachable:
ping [ip_address]

For example, here’s the command I use to see if my PC can talk to my smart home server:

ping command showing success and failed connection
(Press CTRL+C to stop.)

If you get a response with time measurements, the machines can talk to each other. Otherwise, if you get “Destination Host Unreachable” instead, it indicates a connection failure. Ping is the first baseline test I use when I spin up a new server or need to troubleshoot network issues.

ip – Configure Network Interfaces

What name did my OS assign the network interface? What’s its IP? In the past, ifconfig or iwconfig was used for this purpose, but they’re deprecated now. Let’s learn the new command.

The ip command is a tool to manage network interfaces.
You’ll probably use it most often to view your network interface names and IP addresses:
ip a
ip a command

Or you might use it to identify the IP address of the router your device is connected to:
ip route
ip route command on linux

The ip command can do a slew of other functions—like finding the MAC address or helping set a static IP address. For even more examples, check out this guide.

ls – List File Permissions

Everything in Linux is a file. When I can’t figure out why a program won’t run or access something correctly, it often turns out to be an issue with file permissions.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

The ls command used with the -l flag will show permissions for files and folders:
ls -l

I like to add extra flags to display human-readable file sizes and to show all hidden files:

ls command to show file permissions on linux

You’ll have to brush up on what “-rwx-xr-x” and such means in terms of Linux file permissions. Furthermore, the commands chmod (change permission) and chgrp (change ownership) will also be important tools for fixing permission issues.

Note: Want to follow along as you learn the basics of using a terminal? I have a video lesson on this topic just for community members. Join here to watch, and get access to 30+ other lessons for Raspberry Pi along with many other benefits!

find – Search for Files

Oftentimes, I can’t figure out where I put a program or where its config files might be hiding.

The find command searches for files on the system.
To make find easier to use:

  • call it with sudo to avoid permission errors.
  • specify which folder to search.
  • add the case-insensitive flag to make the search more forgiving.

sudo find [folder] -iname [search_term]

find command on linux
(Replace “/var/log” with your desired folder and “unifi” with your desired search term.)

You can also use wildcards (*) to broaden your search (don’t forget to add quotation marks):
sudo find / -iname "*unifi*"

To learn more ways to make file search easy, check out our guide here.

journalctl – Read System Logs

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

One of the best features of Linux over other operating systems is its detailed logging. When something isn’t working, I can peruse the logs and figure out what the errors were.

Logs used to be stored in plain-text. You could read them in /var/log with simple commands like cat, tail, or grep. However, most Linux distros have moved to binary logs. This new approach requires a special command to view them.

The journalctl command is a tool for displaying event logs.
The benefit of this new system is that there are advanced ways to search and filter for what you’re looking for.

For example, you can display logs by date:
journalctl --since "yesterday"
journalctl showing logs from yesterday
Or display logs for a specific service:
journalctl -u [service_name]
journalctl for specific service

There are more complex ways you can use it, so I recommend referring to our journalctl guide for further examples.

systemctl – Manage Services

In the past, Linux services that ran in the background could be set up in different ways. Since every program did it differently, it was a pain to figure out how to modify something. Thankfully, most Linux systems today have moved to a central command to handle services.

The systemctl command is used to control and manage services.

For example, you can:

  • View the status for all services:
    systemctl --type=service
    systemctl view all services
  • View the status of a specific service:
    systemctl status [service_name]
    systemctl status
  • Start/stop a service for this session:
    sudo systemctl start [service_name]
    sudo systemctl stop [service_name]
  • Restart a service:
    sudo systemctl restart [service_name]
  • Autostart a service on boot:
    sudo systemctl enable [service_name]
    systemctl enable to autostart service

We cover more on systemctl in our guide: How To Use ‘systemctl’.

dmesg – Display Kernel-Related Messages

Okay, but what if the methods above haven’t pinpointed my issue? When I want an umbrella overview of everything on my system, I turn to this catch-all command.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

The dmesg command displays diagnostic messages from the Linux kernel.
dmesg

dmesg example output

Using dmesg can tell you everything from CPU behavior to what got plugged into USB ports. The output is overwhelming at first, as it often scrolls over many screens. But if you have an idea of what you’re looking for, you can use grep to filter the output.

I find dmesg especially useful for pinpointing hardware issues. For example, it might tell me that a device isn’t working because it doesn’t have the proper kernel module (driver) support.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Stuck on this project? Ask me or other Pi users in the RaspberryTips Community. We help each other out and you'll get answers quick. Join and fix it together.

lshw – List Hardware

Oftentimes, dmesg is just the start when I have a hardware problem, as it might not tell me the whole picture. The next step I take is to gather more information on the system’s hardware.

The lshw command is a hardware lister:
sudo lshw

lshw output sample

Using lshw to find a device’s name and hardware ID is often key to get it working on a particular Linux distro. It might lead to looking up common issues in the Linux Hardware Database, installing a custom kernel module, or googling a workaround.

You may need to install the lshw package first to access the command. If you want more granular info, there are more flags you can use. In addition, the commands lsusb / lspci / lscpu are also useful for getting more details on specific parts of your system.

(I covered lshw because it’s more commonly available in official repos. But if you want a friendlier output, try installing the package for my personal favorite: inxi.)

inxi command

You’ve reached the end, but if you’re still eager for more, don’t forget to check out our guide to the 50 most useful Linux commands.

These commands will come in handy for diagnostic troubleshooting on Linux. Master them, and like Neo from The Matrix, soon you’ll understand how your system works inside and out.

Whenever you're ready, here are other ways I can help you:

Master Linux Commands: Overwhelmed with Linux commands? This book is your essential guide to mastering the terminal. It includes practical tips, real-world examples, and a bonus cheat sheet to keep by your side.

The RaspberryTips Community: Need help with Linux or want to chat with people who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct support.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts