Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Sadeek M
Sadeek M

Posted on

     

Basic Linux Debugging Guide

Debugging in Linux is essential for troubleshooting system issues, application bugs, or network problems. Here’s a simple guide to get you started with common Linux debugging tools and techniques.

1. Checking System Logs
Linux logs are a great starting point for debugging. Logs capture events related to the kernel, applications, and services.

View Logs with journalctl

# List all processesps aux# View processes in real-timetop
Enter fullscreen modeExit fullscreen mode

Find a Process by Name with pgrep

pgrep <process_name>
Enter fullscreen modeExit fullscreen mode

Debug a Process with strace
strace traces system calls made by a process.

strace -p <pid>`
Enter fullscreen modeExit fullscreen mode

Debug a Process with gdb
gdb is used for debugging compiled applications.

gdb <program_name> <pid>
Enter fullscreen modeExit fullscreen mode
  1. Networking DebuggingCheck Active Connections with netstat or ss

Using netstat

netstat -tuln
Enter fullscreen modeExit fullscreen mode

Using ss

ss -tuln
Enter fullscreen modeExit fullscreen mode

Test Connectivity with ping or curl

ping <hostname_or_ip>
Enter fullscreen modeExit fullscreen mode

curl -v http://
Check Firewall Rules with iptables or ufw

Using iptables

sudo iptables -L -v
Enter fullscreen modeExit fullscreen mode

Using ufw

sudo ufw status verbose
Enter fullscreen modeExit fullscreen mode
  1. Disk and Filesystem DebuggingCheck Disk Usage with df and du

Disk space usage

df -h
Enter fullscreen modeExit fullscreen mode

Directory size usage

du -sh <directory_name>
Enter fullscreen modeExit fullscreen mode

Check Disk Health with fsck and smartctl

Check and repair filesystem (run in unmounted mode)

sudo fsck /dev/sdX
Enter fullscreen modeExit fullscreen mode

Check disk health using smartctl

sudo smartctl -a /dev/sdX
Enter fullscreen modeExit fullscreen mode
  1. Memory DebuggingCheck Memory Usage with free and vmstat

Memory usage

free -h
Enter fullscreen modeExit fullscreen mode

System performance and memory statistics

vmstat 1 5
Enter fullscreen modeExit fullscreen mode

Analyze Memory Leaks with valgrind

valgrind --leak-check=yes ./your_program
Enter fullscreen modeExit fullscreen mode
  1. Kernel DebuggingCheck Kernel Messages with dmesg
dmesg | tail
Enter fullscreen modeExit fullscreen mode

Debug Kernel Panics with kdump
Ensure kdump is installed and configured for capturing kernel crash dumps.

sudo systemctl start kdump
Enter fullscreen modeExit fullscreen mode

Conclusion
Effective debugging in Linux requires a good understanding of system logs, processes, network, disk, and memory. Start with logs, monitor processes, trace system calls, and analyze system resources. Mastering these tools will help you quickly diagnose and resolve issues.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
sunnybhambhani profile image
Sunny Bhambhani
https://www.linkedin.com/in/sunnybhambhani/
  • Location
    India
  • Education
    RTU/AMU
  • Work
    Sr. Technical Manager @ VOIS
  • Joined

Good one!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

https://www.linkedin.com/in/sadeek-mohammad/
  • Joined

More fromSadeek M

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp