$npx -y skills add chaterm/terminal-skills --skill system-adminLinux system administration and monitoring
| 1 | # Linux System Administration |
| 2 | |
| 3 | ## Overview |
| 4 | Core commands and best practices for Linux system administration, including system information viewing, resource monitoring, service management, etc. |
| 5 | |
| 6 | ## System Information |
| 7 | |
| 8 | ### Basic Information |
| 9 | ```bash |
| 10 | # System version |
| 11 | cat /etc/os-release |
| 12 | uname -a |
| 13 | |
| 14 | # Hostname |
| 15 | hostnamectl |
| 16 | |
| 17 | # Uptime and load |
| 18 | uptime |
| 19 | ``` |
| 20 | |
| 21 | ### Hardware Information |
| 22 | ```bash |
| 23 | # CPU information |
| 24 | lscpu |
| 25 | cat /proc/cpuinfo |
| 26 | |
| 27 | # Memory information |
| 28 | free -h |
| 29 | cat /proc/meminfo |
| 30 | |
| 31 | # Disk information |
| 32 | lsblk |
| 33 | df -h |
| 34 | ``` |
| 35 | |
| 36 | ## Resource Monitoring |
| 37 | |
| 38 | ### Real-time Monitoring |
| 39 | ```bash |
| 40 | # Comprehensive monitoring |
| 41 | top |
| 42 | htop |
| 43 | |
| 44 | # Memory monitoring |
| 45 | vmstat 1 |
| 46 | |
| 47 | # IO monitoring |
| 48 | iostat -x 1 |
| 49 | iotop |
| 50 | |
| 51 | # Network monitoring |
| 52 | iftop |
| 53 | nethogs |
| 54 | ``` |
| 55 | |
| 56 | ### Historical Data |
| 57 | ```bash |
| 58 | # System activity report |
| 59 | sar -u 1 10 # CPU |
| 60 | sar -r 1 10 # Memory |
| 61 | sar -d 1 10 # Disk |
| 62 | ``` |
| 63 | |
| 64 | ## Service Management |
| 65 | |
| 66 | ### Systemd Services |
| 67 | ```bash |
| 68 | # Service status |
| 69 | systemctl status service-name |
| 70 | systemctl is-active service-name |
| 71 | |
| 72 | # Start/Stop services |
| 73 | systemctl start/stop/restart service-name |
| 74 | |
| 75 | # Boot startup |
| 76 | systemctl enable/disable service-name |
| 77 | |
| 78 | # View all services |
| 79 | systemctl list-units --type=service |
| 80 | ``` |
| 81 | |
| 82 | ## Common Scenarios |
| 83 | |
| 84 | ### Scenario 1: System Health Check |
| 85 | ```bash |
| 86 | # Quick health check script |
| 87 | echo "=== System Load ===" && uptime |
| 88 | echo "=== Memory Usage ===" && free -h |
| 89 | echo "=== Disk Usage ===" && df -h |
| 90 | echo "=== Failed Services ===" && systemctl --failed |
| 91 | ``` |
| 92 | |
| 93 | ### Scenario 2: Troubleshoot High Load |
| 94 | ```bash |
| 95 | # 1. Check load |
| 96 | uptime |
| 97 | |
| 98 | # 2. Find high CPU processes |
| 99 | ps aux --sort=-%cpu | head -10 |
| 100 | |
| 101 | # 3. Find high memory processes |
| 102 | ps aux --sort=-%mem | head -10 |
| 103 | ``` |
| 104 | |
| 105 | ## Troubleshooting |
| 106 | |
| 107 | | Problem | Commands | |
| 108 | |---------|----------| |
| 109 | | System lag | `top`, `vmstat 1`, `iostat -x 1` | |
| 110 | | Disk full | `df -h`, `du -sh /*`, `ncdu` | |
| 111 | | Memory shortage | `free -h`, `ps aux --sort=-%mem` | |
| 112 | | Service abnormal | `systemctl status`, `journalctl -u` | |