- Devops Diaries
- Posts
- Troubleshooting in Linux System
Troubleshooting in Linux System
From monitoring processes with top to checking firewall rules with iptables, mastering these commands can significantly streamline troubleshooting tasks.

Linux is known for its robustness and reliability, but even the most well-maintained systems occasionally encounter performance and network issues. Mastering essential troubleshooting commands is invaluable for diagnosing and fixing these problems efficiently.
In this post, i will explain 10 fundamental Linux commands that can help you identify and resolve issues related to system performance, network connectivity, and process management.
Each of these commands provides essential insights into different aspects of Linux system performance and functionality. From monitoring processes with top
to checking firewall rules with iptables
, mastering these commands can significantly streamline troubleshooting tasks. Familiarize yourself with these tools to gain more control over your Linux environment and resolve issues efficiently.
1. top
: Monitor System Performance
The top
command provides a real-time view of system resource usage, showing active processes and their CPU and memory consumption.
top
Type
top
and press Enter.Look at the columns to identify processes that are consuming high CPU or memory.
Press
P
to sort by CPU usage, orM
to sort by memory usage.
Tip: Press
q
to exit.
2. dmesg
: Check Kernel Messages
The dmesg
command displays system messages from the kernel, which can be useful for diagnosing hardware and startup issues.
dmesg | tail
Type
dmesg
to see all kernel messages or usedmesg | tail
to view the latest entries.To filter messages, use
dmesg | grep [keyword]
.
Example:
dmesg | grep error
will show recent errors.
3. ping
: Test Network Connectivity
The ping
command checks if your system can reach another system over the network by sending data packets.
ping [destination IP/hostname]
Type
ping google.com
to check if you have internet connectivity.Review the response time to assess latency.
Use
Ctrl+C
to stop the ping test.
Note: If packets are dropped, it may indicate network issues.
4. traceroute
: Analyze Network Path
traceroute
helps you trace the path taken by data packets to reach a destination, allowing you to identify network bottlenecks.
traceroute [destination]
Run
traceroute google.com
to see each hop the packet takes.Review the output for any delays or timeouts.
Tip: Look for high latency at specific hops, which may indicate a problem.
5. netstat
/ ss
: Network Statistics and Connections
These commands display active network connections and listening ports, which is useful for troubleshooting network-related issues.
netstat -tuln
or ss -tuln
Run
netstat -tuln
orss -tuln
to view TCP and UDP connections.The
-tuln
options display active network connections and listening ports.
Example:
ss -tuln | grep LISTEN
shows only listening ports.
6. df
: Disk Usage Analysis
The df
command provides an overview of available disk space across mounted filesystems.
df -h
Type
df -h
to display disk usage in a human-readable format.Identify filesystems nearing full capacity (e.g., over 80% usage).
Tip: Check the
/
(root) partition to ensure there’s enough space for system operations.
7. du
: Directory Usage Insight
Use du
to check how much disk space specific directories are using, which helps in locating large files or folders that may need cleanup.
du -sh [directory]
Type
du -sh /path/to/directory
to see the size of that directory.Use
du -sh * | sort -h
in a directory to list and sort all files by size.
Example:
du -sh /var/log
displays the size of the system log directory.
8. ps
: Process Status and Management
The ps
command shows active processes and their resource consumption, allowing you to identify and manage processes.
ps aux
Run
ps aux
to list all processes with details on user, CPU usage, and memory.Use
ps aux | grep [process_name]
to find a specific process.
Tip: To kill an unresponsive process, use
kill [PID]
, where PID is the process ID.
9. tail
: Log File Analysis
The tail
command displays the end of a file, making it ideal for monitoring real-time log entries.
tail -f /var/log/syslog
Use
tail -f /var/log/syslog
to view the latest system logs as they’re updated.Press
Ctrl+C
to stop monitoring.
Common Files:
/var/log/syslog
– General system events./var/log/auth.log
– Authentication and authorization logs.
10. iptables
: Firewall Rule Checks
iptables
displays or configures firewall rules, allowing you to see which rules may be affecting network connectivity.
sudo iptables -L
Run
sudo iptables -L
to list all active firewall rules.Look for rules that may be blocking or restricting access to specific ports or IPs.
Tip: If you make changes to rules, remember to save them (
sudo iptables-save
).
Familiarize yourself with these tools to gain more control over your Linux environment and resolve issues efficiently.
Reply