finished debugging services
This commit is contained in:
@@ -132,6 +132,7 @@ export default defineConfig({
|
|||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Add User to Linux', link: '/linux/add-user' },
|
{ text: 'Add User to Linux', link: '/linux/add-user' },
|
||||||
|
{ text: 'Debugging Services', link: '/linux/debugging-services' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 <process_name>
|
||||||
|
|
||||||
|
# Java
|
||||||
|
ps aux | grep java
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Find the service if a systemd service is running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generic
|
||||||
|
sudo systemctl status <service_name>
|
||||||
|
|
||||||
|
# Specific service
|
||||||
|
sudo systemctl status myapp
|
||||||
|
|
||||||
|
# Find service
|
||||||
|
sudo systemctl list-units --type=service | grep <service_name>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### View logs for a systemd service
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generic
|
||||||
|
sudo journalctl -u <service_name> -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 <port_number>
|
||||||
|
|
||||||
|
# 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
|
||||||
|
```
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# Linux Snippets and Musings
|
# Linux Snippets and Musings
|
||||||
|
|
||||||
#### [Add User to Linux](./add-user.md)
|
#### [Add User to Linux](./add-user.md)
|
||||||
|
#### [Debugging Services](./debugging-services.md)
|
||||||
Reference in New Issue
Block a user