-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinux System Monitoring
More file actions
106 lines (93 loc) · 2.54 KB
/
Copy pathLinux System Monitoring
File metadata and controls
106 lines (93 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Linux System Monitoring
## Introduction to System Monitoring
Monitoring system resources is essential to ensure optimal performance, detect issues, and troubleshoot problems in Linux. Various tools allow us to monitor CPU, memory, disk usage, network activity, and running processes.
## Index of Commands Covered
### CPU and Memory Monitoring
- `top` – Real-time system monitoring
- `htop` – Interactive process viewer (requires installation)
- `vmstat` – Report system performance statistics
- `free -m` – Show memory usage
### Disk Monitoring
- `df -h` – Check disk space usage
- `du -sh /path` – Show disk usage of a specific directory
- `iostat` – Display CPU and disk I/O statistics
### Network Monitoring
- `ifconfig` – Show network interfaces (deprecated, use `ip a`)
- `ip a` – Show network interface details
- `netstat -tulnp` – Show active connections and listening ports
- `ss -tulnp` – Alternative to `netstat` for socket statistics
- `ping hostname` – Test network connectivity
- `traceroute hostname` – Show network path to a host
- `nslookup domain` – Get DNS resolution details
### Log Monitoring
- `tail -f /var/log/syslog` – Live monitoring of system logs
- `journalctl -f` – Live system logs for systemd-based distros
- `dmesg | tail` – View kernel logs
## CPU and Memory Monitoring
### Using `top`
To view real-time CPU and memory usage:
```bash
top
```
Press `q` to quit.
### Using `htop`
A user-friendly alternative:
```bash
htop
```
Use arrow keys to navigate and `F9` to kill processes.
### Using `vmstat`
To check CPU, memory, and I/O stats:
```bash
vmstat 1 5 # Update every 1 sec, show 5 updates
```
### Checking Memory Usage
```bash
free -m
```
Shows free and used memory in megabytes.
## Disk Monitoring
### Using `df`
Check available disk space:
```bash
df -h
```
### Using `du`
Find the size of a directory:
```bash
du -sh /var/log
```
### Using `iostat`
Check disk and CPU usage:
```bash
iostat
```
## Network Monitoring
### Checking Network Interfaces
```bash
ip a # Show IP addresses and interfaces
```
### Viewing Open Ports and Connections
```bash
netstat -tulnp # Show listening ports
ss -tulnp # Alternative to netstat
```
### Testing Connectivity
```bash
ping google.com # Test internet connection
traceroute google.com # Trace the path to Google
```
### Checking DNS Resolution
```bash
nslookup example.com
```
## Log Monitoring
### Live Monitoring of System Logs
```bash
tail -f /var/log/syslog # Follow logs in real-time
journalctl -f # Systemd logs
```
### Checking Kernel Logs
```bash
dmesg | tail
```