Linux Commands to Troubleshoot Performance Issues

  1. Check System Load : Use the uptime command to check system load and uptime:
uptime

2. Monitor CPU Usage :

top : Provides a real-time view of CPU, memory usage, and processes.

top

3. Memory Usage and Swapping :

free : Use the free command to check memory usage

free -h

4. Disk I/O Performance :

iostat : Use the iostat command to monitor disk I/O performance

iostat

5. Disk Usage :

df : Use the df command to check disk usage

df -h

6. Check Logs for Errors :

tail : Use the tail command to monitor system logs in real-time.

tail -f /var/log/syslog

7. Check for High CPU Processes :

htop : Use the htop command for an interactive process viewer.

htop

8. Check for High Memory Usage :

vmstat : Use the vmstat command to report virtual memory statistics

vmstat

9. Check Memory Usage :

free : The output provides total, used, free memory, and buffers/cache.

free -m

10. System Information and Monitoring :

ps: Display current processes

ps aux

11. Check File Descriptors :

lsof : Lists open files.

lsof | wc -l
lsof -p <PID>

12. Debug System Logs :

dmesg : Prints kernel-related logs.

dmesg | less

13. journalctl : Centralized log viewer.

journalctl -xe

14. Network Performance :

iftop : Real-time network usage per interface.

sudo apt install iftop
sudo iftop

15. netstat : Displays network connections.

netstat -tulnp

16. Check CPU Utilization :

mpstat : Displays CPU usage for all cores.

sudo apt install sysstat
mpstat -P ALL 1

17. Pidstat : This command monitors tasks managed by the Linux kernel.

pidstat 

18. Sar : This command is part of the sysstat package and provides performance monitoring.

sar

19. Dstat : This command combines vmstat, iostat, and other tools to provide a comprehensive view of system performance.

dstat

20. auditd: System auditing tool

sudo systemctl start auditd

21. fail2ban: Ban malicious IP addresses

fail2ban-client status

22. iptables: Configure firewall rules

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

23. ufw: User-friendly firewall

sudo ufw allow ssh

24. traceroute: Trace the route packets take

traceroute google.com

25. nslookup: Query DNS nameservers

nslookup google.com

26. ss: Show socket statistics

ss -tanlp

Leave a Comment