# Debugging Services The below are a bunch of commands that can be used to debug services on a Linux system (e.g. Java App / .NET App and so on) #### Finding the process ```bash # Generic ps aux | grep # Java ps aux | grep java ``` #### Find the service if a systemd service is running ```bash # Generic sudo systemctl status # Specific service sudo systemctl status myapp # Find service sudo systemctl list-units --type=service | grep ``` #### View logs for a systemd service ```bash # Generic sudo journalctl -u -n 100 --no-pager # Specific service sudo journalctl -u myapp -n 100 --no-pager ``` #### Check port for a service ```bash # Generic sudo ss -tulpn | grep # Specific port sudo ss -tulpn | grep 8080 ``` #### Search for OOM (Out of Memory) errors in logs ```bash # Generic sudo journalctl -k | grep -i "out of memory|kill|oom" | tail -n 100 sudo dmesg | grep -i "out of memory|kill|oom" | tail -n 100 ``` #### System resource usage ```bash # Display memory usage free -h # Disc usage df -h # Usage on a specific directory du -sh /path/to/directory | sort -rh # CPU top htop ```