diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 0cd5555..091286f 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -132,6 +132,7 @@ export default defineConfig({ collapsed: true, items: [ { text: 'Add User to Linux', link: '/linux/add-user' }, + { text: 'Debugging Services', link: '/linux/debugging-services' } ] }, { diff --git a/docs/linux/debugging-services.md b/docs/linux/debugging-services.md new file mode 100644 index 0000000..bbeaf35 --- /dev/null +++ b/docs/linux/debugging-services.md @@ -0,0 +1,71 @@ +# 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 +``` diff --git a/docs/linux/index.md b/docs/linux/index.md index 7e1fd46..cc9b675 100644 --- a/docs/linux/index.md +++ b/docs/linux/index.md @@ -1,3 +1,4 @@ # Linux Snippets and Musings -#### [Add User to Linux](./add-user.md) \ No newline at end of file +#### [Add User to Linux](./add-user.md) +#### [Debugging Services](./debugging-services.md) \ No newline at end of file