When things go wrong with your Linux system, whether it’s a crash, unresponsive program, or hardware issue, having the right troubleshooting tools at your disposal can save you hours of frustration.
That's why I am going to cover 10 Linux commands that should be in every sysadmin’s toolkit.
Whether you’re a beginner or an experienced pro, these can help you diagnose and resolve problems quickly.
Let's dive in!
10 Crucial Linux Commands For Troubleshooting
dmesg
This command displays kernel messages, giving you insight into hardware events, system startup, and device errors.
It’s a great starting point if you’re troubleshooting issues like a USB device failing to mount.
You can even pipe dmesg with tail to view the most recent logs for a quick look at any errors.
journalctl
If you need a deeper dive into system logs, journalctl pulls logs from the systemd journal and provides detailed error context.
Use the -xe flag to show recent logs and pinpoint issues such as crashes or service failures.
htop
This interactive real-time resource monitor shows CPU and memory usage, helping you identify which processes are consuming excessive resources.
It’s an upgrade from the traditional top command and offers a colorful and user-friendly interface.
ps aux
This command lists all running processes, showing details like process ID (PID), CPU usage, and memory consumption.
Use this to verify if a service is running or to identify resource-hogging processes.
Piping it with grep also allows you to search for specific processes.
strace
strace traces system calls made by a process, which can be extremely helpful for debugging applications that are failing or hanging.
By using this, you can see what a process is doing behind the scenes and pinpoint where it’s getting stuck.
lsof
If you’re dealing with locked files or hanging network connections, lsof lists all open files, including network ports and connections.
Adding the -i flag shows processes using network connections, which can help you identify any issues related to network connectivity.
ping
A simple yet essential tool, ping checks network connectivity by sending ICMP packets to a remote host and measuring the response time.
It’s a great way to test for network or DNS issues that might be affecting your system’s communication with other devices.
ss
For more detailed network statistics, ss lists open sockets, network connections, and listening ports.
It’s a faster and more informative replacement for netstat, allowing you to troubleshoot network issues effectively.
df
The df command displays disk space usage for each file system. Use the -h flag to get human-readable output, which helps you quickly identify whether your system is running low on disk space, potentially causing performance issues.
uptime
This command shows how long your system has been running along with load averages for the past 1, 5, and 15 minutes.
It’s a simple yet effective way to check system stability and determine if your system is under heavy load.
Wrapping Up
If you spend any time at the terminal, these 10 commands are essential for troubleshooting performance problems, fixing network connectivity issues, or debugging system processes.
Trust me, mastering these commands will make you more efficient at diagnosing and resolving problems, helping you keep your system running smoothly.