Troubleshooting an application in Linux

Posted by

Troubleshooting an application in Linux involves a systematic approach to diagnose and resolve issues. Here are some steps and commands to help you troubleshoot applications effectively:

1. Check Application Status

Using systemctl

  • For applications managed by systemd:
sudo systemctl status <application_name>

sudo systemctl status apache2

Using ps

  • To check if the application process is running:
ps aux | grep <application_name>
ps aux | grep nginx

2. Check Application Logs

Most applications write logs to /var/log or their own log directories.

Using less, tail, and grep

  • View logs:
less /var/log/<application_name>/error.log

Follow logs in real-time:

tail -f /var/log/<application_name>/error.log

Search logs for specific errors:

grep "error" /var/log/<application_name>/error.log

3. Check System Resource Usage

Using top and htop

  • top: Provides a dynamic real-time view of system processes.

htop: More user-friendly version of top.

sudo apt install htop   # Debian/Ubuntu
sudo yum install htop   # CentOS/RHEL

Using free

  • Check memory usage:
free -h

Using df

  • Check disk usage:
df -h

4. Network Connectivity

Using ping

  • Check if the server is reachable
ping <hostname_or_ip>

Using netstat

  • Check for open ports and listening services
netstat -tuln

Using ss

  • Another tool to investigate sockets
ss -tuln

Using curl or wget

  • Test HTTP/S endpoints:
curl -I http://<hostname_or_ip>
wget http://<hostname_or_ip>

5. Permission Issues

Using ls and chmod

  • Check file permissions:
ls -l /path/to/application/file

Change file permissions:

sudo chmod 755 /path/to/application/file

Using chown

  • Change file ownership
sudo chown user:group /path/to/application/file

6. Dependency and Configuration Issues

Check Configuration Files

  • Open and check the application’s configuration files for errors or misconfigurations:
less /etc/<application_name>/config.conf

Check Dependencies

  • Ensure all required dependencies are installed:
sudo apt install <dependency_name>   # Debian/Ubuntu
sudo yum install <dependency_name>   # CentOS/RHEL

7. Application-Specific Troubleshooting

Each application may have its own set of troubleshooting steps. Here are examples for common applications:

Apache (HTTPD)

  • Check Apache Configuration:
apachectl configtest

Restart Apache:

sudo systemctl restart apache2   # Debian/Ubuntu
sudo systemctl restart httpd     # CentOS/RHEL


  • Check MySQL Status:
sudo systemctl status mysql

Check MySQL Logs:

less /var/log/mysql/error.log

Restart MySQL:

sudo systemctl restart mysql

8. Debugging Tools

Using strace

  • Trace system calls and signals:
strace -p <pid>

Using gdb

  • Debug programs:
gdb /path/to/application <pid>


  1. Check Application Status: Use systemctl or ps.
  2. Check Logs: Use less, tail, and grep to view and search logs.
  3. Check System Resources: Use top, htop, free, and df.
  4. Network Connectivity: Use ping, netstat, ss, curl, and wget.
  5. Permission Issues: Use ls, chmod, and chown.
  6. Dependencies and Configuration: Check configuration files and install necessary dependencies.
  7. Application-Specific Steps: Follow application-specific troubleshooting steps.
  8. Debugging Tools: Use strace and gdb for in-depth debugging.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x