━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 SKILL ACTIVATED: systems-engineering
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Systems Engineering & Administration
Comprehensive guide for Linux and Windows system administration, networking, performance optimization, configuration management, and operational automation. This skill provides production-tested patterns for managing infrastructure at scale across both platforms.
When to Use This Skill
Automatically activates when working on:
- Linux or Windows Server administration and configuration
- System performance tuning and optimization
- Configuration management (Ansible, Chef, Puppet, DSC)
- Shell scripting automation (bash, PowerShell)
- System monitoring and observability setup
- Security hardening and compliance
- Storage management and backup strategies
- Active Directory and Group Policy (Windows)
- System troubleshooting and debugging
Overview
Purpose: Enable teams to build, configure, and maintain robust infrastructure with automation, monitoring, and performance optimization on both Linux and Windows platforms.
Scope:
- Linux and Windows Server administration
- Networking fundamentals (TCP/IP, DNS, load balancing, firewalls)
- Performance tuning and optimization (both platforms)
- Configuration management (Ansible, Chef, Puppet, DSC)
- System monitoring and observability
- Shell scripting and automation (bash, PowerShell)
- Troubleshooting and debugging
- Security hardening (Linux and Windows)
- Storage management (LVM, Windows Storage Spaces)
- Operational excellence
This skill is for:
- Systems engineers managing Linux and Windows infrastructure
- DevOps engineers automating operations across platforms
- SREs optimizing system performance
- IT administrators maintaining servers (Linux/Windows)
- Platform engineers building foundational services
Quick Start Checklist
When starting a systems engineering task:
Core Concepts
1. Linux System Architecture
┌─────────────────────────────────────────────────────────────┐
│ User Space │
│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │
│ │ Applications│ Libraries │ System Utils │ Shells │ │
│ └────────────┴─────────────┴──────────────┴──────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Kernel Space │
│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │
│ │ Process │ Memory │ File System │ Network │ │
│ │ Management │ Management │ Management │ Stack │ │
│ └────────────┴─────────────┴──────────────┴──────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Hardware Layer │
│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │
│ │ CPU │ RAM │ Storage │ Network │ │
│ │ │ │ │ Interfaces │ │
│ └────────────┴─────────────┴──────────────┴──────────────┘ │
└─────────────────────────────────────────────────────────────┘
2. systemd Service Management
Service Lifecycle:
┌──────────┐ systemctl start ┌──────────┐
│ │ ──────────────────→ │ │
│ Inactive │ │ Active │
│ │ ←────────────────── │ │
└──────────┘ systemctl stop └──────────┘
↓ ↓
└─────→ systemctl enable ──────→ (starts on boot)
Key Commands:
# Service management
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx
systemctl status nginx
# Enable/disable at boot
systemctl enable nginx
systemctl disable nginx
# View logs
journalctl -u nginx
journalctl -u nginx -f # Follow
journalctl -u nginx --since "1 hour ago"
# List all services
systemctl list-units --type=service
systemctl list-unit-files --type=service
3. Networking Stack
┌─────────────────────────────────────────────────────────────┐
│ Layer 7: Application (HTTP, DNS, SSH, FTP) │
├─────────────────────────────────────────────────────────────┤
│ Layer 4: Transport (TCP, UDP) │
├─────────────────────────────────────────────────────────────┤
│ Layer 3: Network (IP, ICMP, Routing) │
├─────────────────────────────────────────────────────────────┤
│ Layer 2: Data Link (Ethernet, MAC addresses) │
├─────────────────────────────────────────────────────────────┤
│ Layer 1: Physical (Cables, NICs) │
└─────────────────────────────────────────────────────────────┘
Common Network Operations:
# Interface management
ip addr show
ip link show
ip route show
# Network connectivity
ping -c 4 google.com
traceroute google.com
mtr google.com # Continuous traceroute
# DNS lookup
dig example.com
nslookup example.com
host example.com
# Port scanning
nmap -sT localhost
ss -tuln # Show listening ports
netstat -tuln # Legacy alternative
# Network statistics
ss -s
netstat -i
iftop # Real-time bandwidth
4. Performance Monitoring
System Resource Overview:
# CPU
top
htop
mpstat 1 # CPU stats per second
pidstat 1 # Per-process CPU
# Memory
free -h
vmstat 1
cat /proc/meminfo
# Disk I/O
iostat -x 1
iotop
df -h # Disk usage
du -sh /var/* # Directory sizes
# Network
iftop
nethogs
sar -n DEV 1 # Network stats
Common Patterns
Pattern 1: Ansible Automation
Directory Structure:
ansible/
├── ansible.cfg
├── inventory/
│ ├── production/
│ │ ├── hosts
│ │ └── group_vars/
│ │ ├── all.yml
│ │ ├── webservers.yml
│ │ └── databases.yml
│ └── staging/
│ └── hosts
├── roles/
│ ├── common/
│ │ ├── tasks/
│ │ │ └── main.yml
│ │ ├── handlers/
│ │ │ └── main.yml
│ │ ├── templates/
│ │ ├── files/
│ │ └── vars/
│ │ └── main.yml
│ ├── nginx/
│ └── postgres/
├── playbooks/
│ ├── site.yml
│ ├── webservers.yml
│ └── database.yml
└── group_vars/
└── all.yml
Example Playbook:
# playbooks/webservers.yml
---
- name: Configure web servers
hosts: webservers
become: yes
vars:
nginx_port: 80
app_user: webapp
tasks:
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
- name: Install nginx
apt:
name: nginx
state: present
- name: Configure nginx
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
owner: root
group: root
mode: '0644'
notify: Reload nginx
- name: Ensure nginx is running
systemd:
name: nginx
state: started
enabled: yes
- name: Configure firewall
ufw:
rule: allow
port: '{{ nginx_port }}'
proto: tcp
handlers:
- name: Reload nginx
systemd:
name: nginx
state: reloaded
Pattern 2: System Hardening
Security Baseline Script:
#!/bin/bash
# system-hardening.sh
# Implements CIS benchmark controls
set -euo pipefail
echo "=== System Hardening Script ==="
# 1. Update system
echo "[1/10] Updating system packages..."
apt-get update && apt-get upgrade -y
# 2. Configure firewall
echo "[2/10] Configuring firewall..."
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp # SSH
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
ufw --force enable
# 3. Disable unnecessary services
echo "[3/10] Disabling unnecessary services..."
systemctl disable avahi-daemon 2>/dev/null || true
systemctl disable cups 2>/dev/null || true
systemctl stop avahi-daemon 2>/dev/null || true
systemctl stop cups 2>/dev/null || true
# 4. Configure SSH hardening
echo "[4/10] Hardening SSH configuration..."
cat > /etc/ssh/sshd_config.d/99-hardening.conf <<EOF
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
X11Forwarding no
MaxAuthTries 3
MaxSessions 2
ClientAliveInterval 300
ClientAliveCountMax 2
Protocol 2
EOF
systemctl restart sshd
# 5. Set password policy
echo "[5/10] Configuring password policy..."
cat > /etc/security/pwquality.conf <<EOF
minlen = 14
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
EOF
# 6. Configure auditd
echo "[6/10] Setting up audit logging..."
apt-get install -y auditd audispd-plugins
systemctl enable auditd
systemctl start auditd
# 7. Kernel hardening
echo "[7/10] Applying kernel hardening..."
cat > /etc/sysctl.d/99-hardening.conf <<EOF
# IP forwarding
net.ipv4.ip_forward = 0
# SYN flood protection
net.ipv4.tcp_syncookies = 1
# ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
# Source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Log martians
net.ipv4.conf.all.log_martians = 1
# Ignore ICMP ping
net.ipv4.icmp_echo_ignore_all = 0
# IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
EOF
sysctl -p /etc/sysctl.d/99-hardening.conf
# 8. File permissions
echo "[8/10] Setting secure file permissions..."
chmod 600 /etc/ssh/sshd_config
chmod 644 /etc/passwd
chmod 640 /etc/shadow
chmod 640 /etc/gshadow
# 9. Install security tools
echo "[9/10] Installing security tools..."
apt-get install -y \
fail2ban \
rkhunter \
aide
# Configure fail2ban
systemctl enable fail2ban
systemctl start fail2ban
# 10. Set up automatic updates
echo "[10/10] Configuring automatic security updates..."
apt-get install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
echo "=== System Hardening Complete ==="
echo "Please review /var/log/system-hardening.log for details"
Pattern 3: Performance Tuning
Performance Analysis Script:
#!/bin/bash
# performance-check.sh
# Analyzes system performance and provides recommendations
echo "=== System Performance Analysis ==="
echo ""
# CPU Analysis
echo "--- CPU Information ---"
echo "CPU Model: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d: -f2 | xargs)"
echo "CPU Cores: $(nproc)"
echo "Load Average (1m, 5m, 15m): $(uptime | awk -F'load average:' '{print $2}')"
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
echo "CPU Usage: ${CPU_USAGE}%"
if (( $(echo "$CPU_USAGE > 80" | bc -l) )); then
echo "⚠ WARNING: High CPU usage detected"
echo "Top CPU consumers:"
ps aux --sort=-%cpu | head -6
fi
echo ""
# Memory Analysis
echo "--- Memory Information ---"
free -h
MEMORY_USAGE=$(free | grep Mem | awk '{print ($3/$2) * 100.0}')
echo "Memory Usage: ${MEMORY_USAGE}%"
if (( $(echo "$MEMORY_USAGE > 90" | bc -l) )); then
echo "⚠ WARNING: High memory usage detected"
echo "Top memory consumers:"
ps aux --sort=-%mem | head -6
fi
echo ""
# Disk I/O Analysis
echo "--- Disk I/O Information ---"
iostat -x 1 2 | tail -n +4
echo ""
# Network Analysis
echo "--- Network Information ---"
echo "Network Interfaces:"
ip -brief addr show
echo ""
echo "Network Connections:"
ss -s
echo ""
echo "Top Bandwidth Consumers:"
netstat -tunap 2>/dev/null | grep ESTABLISHED | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head -5
echo ""
echo "=== Performance Analysis Complete ==="
Resource Files
For detailed guidance on specific topics, see:
Linux Administration
- linux-administration.md - systemd, user management, package managers, LVM, file systems, boot process
- storage-management.md - LVM operations, RAID, file systems, backups, snapshots, capacity planning
- shell-scripting.md - Bash scripting patterns, error handling, testing, best practices
Windows Administration
- windows-administration.md - Windows Server, Active Directory, GPO, IIS, services, registry, security hardening
- powershell-scripting.md - PowerShell fundamentals, scripting, DSC, remote management, best practices
Networking
- networking-fundamentals.md - TCP/IP, DNS, load balancers, firewalls, routing, network debugging
- security-hardening.md - OS hardening, CIS benchmarks, firewall, SELinux/AppArmor, SSH, audit logging
Performance & Troubleshooting
- performance-tuning.md - CPU optimization, memory tuning, disk I/O, network performance, profiling tools
- troubleshooting-guide.md - Debugging methodology, diagnostic tools, common issues, log analysis
Automation & Configuration
- configuration-management.md - Ansible playbooks, Chef cookbooks, Puppet manifests, DSC, best practices
- automation-patterns.md - Cron jobs, systemd timers, Task Scheduler, idempotency, error handling
Monitoring
- system-monitoring.md - Log aggregation, metrics collection, dashboards, alerting, monitoring best practices
Best Practices
System Administration
Automation First:
- Use configuration management tools
- Version control all configurations
- Implement Infrastructure as Code
- Automate repetitive tasks
- Document automation procedures
Security:
- Principle of least privilege
- Regular security updates
- Implement firewall rules
- Enable audit logging
- Use SSH keys, disable password auth
Monitoring:
- Comprehensive system monitoring
- Centralized logging
- Proactive alerting
- Regular performance reviews
- Capacity planning
Configuration Management
Idempotency:
- Ensure scripts can run multiple times safely
- Check state before making changes
- Use declarative configurations
- Test thoroughly before production
Version Control:
- Store all configs in Git
- Use branches for testing
- Tag releases
- Document changes in commit messages
Testing:
- Test in staging environment
- Use linters (ansible-lint, shellcheck)
- Implement smoke tests
- Rollback procedures ready
Performance Optimization
Measure First:
- Baseline performance metrics
- Identify bottlenecks before optimizing
- Use profiling tools
- Monitor after changes
Incremental Changes:
- One change at a time
- Measure impact
- Document tuning parameters
- Rollback if degraded
Right-Sizing:
- Match resources to workload
- Monitor utilization
- Scale when needed
- Avoid over-provisioning
Anti-Patterns to Avoid
❌ Manual configuration - Not repeatable, error-prone
❌ Root login enabled - Security vulnerability
❌ No monitoring - Can't detect issues
❌ No backups - Risk of data loss
❌ Outdated packages - Security vulnerabilities
❌ Single point of failure - No redundancy
❌ No documentation - Knowledge silos
❌ Direct production changes - Should use config management
❌ Ignoring logs - Miss critical information
❌ No testing - Changes break production
Common Tasks
Task: Configure New Linux Server
- Initial setup and security hardening
- Configure firewall rules
- Set up SSH key authentication
- Install and configure monitoring agent
- Configure log forwarding
- Apply configuration management
- Install required packages
- Configure backups
- Document server in inventory
- Test and validate
Task: Troubleshoot Performance Issue
- Identify symptoms (slow response, high CPU)
- Check system metrics (CPU, memory, disk, network)
- Review logs for errors
- Identify resource bottleneck
- Analyze top processes
- Check for configuration issues
- Implement fix or optimization
- Monitor after changes
- Document root cause and solution
Task: Automate with Ansible
- Design automation workflow
- Create inventory file
- Write playbook and roles
- Test in development environment
- Use ansible-lint for validation
- Test in staging environment
- Document playbook purpose and variables
- Deploy to production
- Monitor execution
- Update runbooks
Integration Points
This skill integrates with:
- platform-engineering: Container hosts, Kubernetes nodes, infrastructure automation
- devsecops: Security scanning, hardening, compliance checks
- sre: System reliability, performance optimization, incident response
- cloud-engineering: Cloud VM management, networking, hybrid cloud
- release-engineering: Deployment automation, server provisioning
Triggers and Activation
This skill activates when you:
- Work with Linux systems or servers
- Configure networking or firewalls
- Write shell scripts or automation
- Troubleshoot system issues
- Tune performance or optimize resources
- Implement configuration management (Ansible, Chef, Puppet)
- Set up monitoring or logging
- Manage storage or file systems
Next Steps
For your specific task:
- Identify the systems engineering requirements
- Review relevant patterns and best practices
- Choose appropriate tools and automation approach
- Implement with configuration management
- Test thoroughly in non-production
- Monitor and iterate based on feedback
Total Resources: 10 detailed guides covering all aspects of systems engineering
Pattern Library: 100+ production-tested patterns for Linux administration and automation
Maintained by: Systems Engineering team based on real-world production experience
1---2name: systems-engineering3description: Systems engineering and administration covering Linux and Windows administration, networking fundamentals, performance tuning, configuration management (Ansible/Chef/Puppet), system monitoring, shell scripting (bash/PowerShell), and troubleshooting. Use when managing Linux or Windows systems, optimizing performance, automating operations, or debugging system issues. (project)4---5━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━6🎯 SKILL ACTIVATED: systems-engineering7━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━8910# Systems Engineering & Administration1112Comprehensive guide for Linux and Windows system administration, networking, performance optimization, configuration management, and operational automation. This skill provides production-tested patterns for managing infrastructure at scale across both platforms.1314## When to Use This Skill1516Automatically activates when working on:17- Linux or Windows Server administration and configuration18- System performance tuning and optimization19- Configuration management (Ansible, Chef, Puppet, DSC)20- Shell scripting automation (bash, PowerShell)21- System monitoring and observability setup22- Security hardening and compliance23- Storage management and backup strategies24- Active Directory and Group Policy (Windows)25- System troubleshooting and debugging2627## Overview2829**Purpose:** Enable teams to build, configure, and maintain robust infrastructure with automation, monitoring, and performance optimization on both Linux and Windows platforms.3031**Scope:**32- Linux and Windows Server administration33- Networking fundamentals (TCP/IP, DNS, load balancing, firewalls)34- Performance tuning and optimization (both platforms)35- Configuration management (Ansible, Chef, Puppet, DSC)36- System monitoring and observability37- Shell scripting and automation (bash, PowerShell)38- Troubleshooting and debugging39- Security hardening (Linux and Windows)40- Storage management (LVM, Windows Storage Spaces)41- Operational excellence4243**This skill is for:**44- Systems engineers managing Linux and Windows infrastructure45- DevOps engineers automating operations across platforms46- SREs optimizing system performance47- IT administrators maintaining servers (Linux/Windows)48- Platform engineers building foundational services4950## Quick Start Checklist5152When starting a systems engineering task:5354- [ ] Identify system requirements (OS, resources, networking)55- [ ] Plan infrastructure topology and dependencies56- [ ] Implement configuration management for reproducibility57- [ ] Set up monitoring and alerting58- [ ] Configure logging and log aggregation59- [ ] Implement security hardening (firewall, SELinux, patches)60- [ ] Document runbooks and procedures61- [ ] Test disaster recovery procedures62- [ ] Implement backup strategy63- [ ] Plan capacity and performance optimization6465## Core Concepts6667### 1. Linux System Architecture6869```70┌─────────────────────────────────────────────────────────────┐71│ User Space │72│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │73│ │ Applications│ Libraries │ System Utils │ Shells │ │74│ └────────────┴─────────────┴──────────────┴──────────────┘ │75├─────────────────────────────────────────────────────────────┤76│ Kernel Space │77│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │78│ │ Process │ Memory │ File System │ Network │ │79│ │ Management │ Management │ Management │ Stack │ │80│ └────────────┴─────────────┴──────────────┴──────────────┘ │81├─────────────────────────────────────────────────────────────┤82│ Hardware Layer │83│ ┌────────────┬─────────────┬──────────────┬──────────────┐ │84│ │ CPU │ RAM │ Storage │ Network │ │85│ │ │ │ │ Interfaces │ │86│ └────────────┴─────────────┴──────────────┴──────────────┘ │87└─────────────────────────────────────────────────────────────┘88```8990### 2. systemd Service Management9192**Service Lifecycle:**93```94┌──────────┐ systemctl start ┌──────────┐95│ │ ──────────────────→ │ │96│ Inactive │ │ Active │97│ │ ←────────────────── │ │98└──────────┘ systemctl stop └──────────┘99 ↓ ↓100 └─────→ systemctl enable ──────→ (starts on boot)101```102103**Key Commands:**104```bash105# Service management106systemctl start nginx107systemctl stop nginx108systemctl restart nginx109systemctl reload nginx110systemctl status nginx111112# Enable/disable at boot113systemctl enable nginx114systemctl disable nginx115116# View logs117journalctl -u nginx118journalctl -u nginx -f # Follow119journalctl -u nginx --since "1 hour ago"120121# List all services122systemctl list-units --type=service123systemctl list-unit-files --type=service124```125126### 3. Networking Stack127128```129┌─────────────────────────────────────────────────────────────┐130│ Layer 7: Application (HTTP, DNS, SSH, FTP) │131├─────────────────────────────────────────────────────────────┤132│ Layer 4: Transport (TCP, UDP) │133├─────────────────────────────────────────────────────────────┤134│ Layer 3: Network (IP, ICMP, Routing) │135├─────────────────────────────────────────────────────────────┤136│ Layer 2: Data Link (Ethernet, MAC addresses) │137├─────────────────────────────────────────────────────────────┤138│ Layer 1: Physical (Cables, NICs) │139└─────────────────────────────────────────────────────────────┘140```141142**Common Network Operations:**143```bash144# Interface management145ip addr show146ip link show147ip route show148149# Network connectivity150ping -c 4 google.com151traceroute google.com152mtr google.com # Continuous traceroute153154# DNS lookup155dig example.com156nslookup example.com157host example.com158159# Port scanning160nmap -sT localhost161ss -tuln # Show listening ports162netstat -tuln # Legacy alternative163164# Network statistics165ss -s166netstat -i167iftop # Real-time bandwidth168```169170### 4. Performance Monitoring171172**System Resource Overview:**173```bash174# CPU175top176htop177mpstat 1 # CPU stats per second178pidstat 1 # Per-process CPU179180# Memory181free -h182vmstat 1183cat /proc/meminfo184185# Disk I/O186iostat -x 1187iotop188df -h # Disk usage189du -sh /var/* # Directory sizes190191# Network192iftop193nethogs194sar -n DEV 1 # Network stats195```196197## Common Patterns198199### Pattern 1: Ansible Automation200201**Directory Structure:**202```203ansible/204├── ansible.cfg205├── inventory/206│ ├── production/207│ │ ├── hosts208│ │ └── group_vars/209│ │ ├── all.yml210│ │ ├── webservers.yml211│ │ └── databases.yml212│ └── staging/213│ └── hosts214├── roles/215│ ├── common/216│ │ ├── tasks/217│ │ │ └── main.yml218│ │ ├── handlers/219│ │ │ └── main.yml220│ │ ├── templates/221│ │ ├── files/222│ │ └── vars/223│ │ └── main.yml224│ ├── nginx/225│ └── postgres/226├── playbooks/227│ ├── site.yml228│ ├── webservers.yml229│ └── database.yml230└── group_vars/231 └── all.yml232```233234**Example Playbook:**235```yaml236# playbooks/webservers.yml237---238- name: Configure web servers239 hosts: webservers240 become: yes241 vars:242 nginx_port: 80243 app_user: webapp244245 tasks:246 - name: Update apt cache247 apt:248 update_cache: yes249 cache_valid_time: 3600250251 - name: Install nginx252 apt:253 name: nginx254 state: present255256 - name: Configure nginx257 template:258 src: nginx.conf.j2259 dest: /etc/nginx/nginx.conf260 owner: root261 group: root262 mode: '0644'263 notify: Reload nginx264265 - name: Ensure nginx is running266 systemd:267 name: nginx268 state: started269 enabled: yes270271 - name: Configure firewall272 ufw:273 rule: allow274 port: '{{ nginx_port }}'275 proto: tcp276277 handlers:278 - name: Reload nginx279 systemd:280 name: nginx281 state: reloaded282```283284### Pattern 2: System Hardening285286**Security Baseline Script:**287```bash288#!/bin/bash289# system-hardening.sh290# Implements CIS benchmark controls291292set -euo pipefail293294echo "=== System Hardening Script ==="295296# 1. Update system297echo "[1/10] Updating system packages..."298apt-get update && apt-get upgrade -y299300# 2. Configure firewall301echo "[2/10] Configuring firewall..."302ufw default deny incoming303ufw default allow outgoing304ufw allow 22/tcp # SSH305ufw allow 80/tcp # HTTP306ufw allow 443/tcp # HTTPS307ufw --force enable308309# 3. Disable unnecessary services310echo "[3/10] Disabling unnecessary services..."311systemctl disable avahi-daemon 2>/dev/null || true312systemctl disable cups 2>/dev/null || true313systemctl stop avahi-daemon 2>/dev/null || true314systemctl stop cups 2>/dev/null || true315316# 4. Configure SSH hardening317echo "[4/10] Hardening SSH configuration..."318cat > /etc/ssh/sshd_config.d/99-hardening.conf <<EOF319PermitRootLogin no320PasswordAuthentication no321PubkeyAuthentication yes322X11Forwarding no323MaxAuthTries 3324MaxSessions 2325ClientAliveInterval 300326ClientAliveCountMax 2327Protocol 2328EOF329systemctl restart sshd330331# 5. Set password policy332echo "[5/10] Configuring password policy..."333cat > /etc/security/pwquality.conf <<EOF334minlen = 14335dcredit = -1336ucredit = -1337ocredit = -1338lcredit = -1339EOF340341# 6. Configure auditd342echo "[6/10] Setting up audit logging..."343apt-get install -y auditd audispd-plugins344systemctl enable auditd345systemctl start auditd346347# 7. Kernel hardening348echo "[7/10] Applying kernel hardening..."349cat > /etc/sysctl.d/99-hardening.conf <<EOF350# IP forwarding351net.ipv4.ip_forward = 0352353# SYN flood protection354net.ipv4.tcp_syncookies = 1355356# ICMP redirects357net.ipv4.conf.all.accept_redirects = 0358net.ipv4.conf.default.accept_redirects = 0359360# Source routing361net.ipv4.conf.all.accept_source_route = 0362net.ipv4.conf.default.accept_source_route = 0363364# Log martians365net.ipv4.conf.all.log_martians = 1366367# Ignore ICMP ping368net.ipv4.icmp_echo_ignore_all = 0369370# IPv6371net.ipv6.conf.all.disable_ipv6 = 1372net.ipv6.conf.default.disable_ipv6 = 1373EOF374sysctl -p /etc/sysctl.d/99-hardening.conf375376# 8. File permissions377echo "[8/10] Setting secure file permissions..."378chmod 600 /etc/ssh/sshd_config379chmod 644 /etc/passwd380chmod 640 /etc/shadow381chmod 640 /etc/gshadow382383# 9. Install security tools384echo "[9/10] Installing security tools..."385apt-get install -y \386 fail2ban \387 rkhunter \388 aide389390# Configure fail2ban391systemctl enable fail2ban392systemctl start fail2ban393394# 10. Set up automatic updates395echo "[10/10] Configuring automatic security updates..."396apt-get install -y unattended-upgrades397dpkg-reconfigure -plow unattended-upgrades398399echo "=== System Hardening Complete ==="400echo "Please review /var/log/system-hardening.log for details"401```402403### Pattern 3: Performance Tuning404405**Performance Analysis Script:**406```bash407#!/bin/bash408# performance-check.sh409# Analyzes system performance and provides recommendations410411echo "=== System Performance Analysis ==="412echo ""413414# CPU Analysis415echo "--- CPU Information ---"416echo "CPU Model: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d: -f2 | xargs)"417echo "CPU Cores: $(nproc)"418echo "Load Average (1m, 5m, 15m): $(uptime | awk -F'load average:' '{print $2}')"419420CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')421echo "CPU Usage: ${CPU_USAGE}%"422423if (( $(echo "$CPU_USAGE > 80" | bc -l) )); then424 echo "⚠ WARNING: High CPU usage detected"425 echo "Top CPU consumers:"426 ps aux --sort=-%cpu | head -6427fi428429echo ""430431# Memory Analysis432echo "--- Memory Information ---"433free -h434MEMORY_USAGE=$(free | grep Mem | awk '{print ($3/$2) * 100.0}')435echo "Memory Usage: ${MEMORY_USAGE}%"436437if (( $(echo "$MEMORY_USAGE > 90" | bc -l) )); then438 echo "⚠ WARNING: High memory usage detected"439 echo "Top memory consumers:"440 ps aux --sort=-%mem | head -6441fi442443echo ""444445# Disk I/O Analysis446echo "--- Disk I/O Information ---"447iostat -x 1 2 | tail -n +4448449echo ""450451# Network Analysis452echo "--- Network Information ---"453echo "Network Interfaces:"454ip -brief addr show455456echo ""457echo "Network Connections:"458ss -s459460echo ""461echo "Top Bandwidth Consumers:"462netstat -tunap 2>/dev/null | grep ESTABLISHED | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head -5463464echo ""465echo "=== Performance Analysis Complete ==="466```467468## Resource Files469470For detailed guidance on specific topics, see:471472### Linux Administration473- **[linux-administration.md](resources/linux-administration.md)** - systemd, user management, package managers, LVM, file systems, boot process474- **[storage-management.md](resources/storage-management.md)** - LVM operations, RAID, file systems, backups, snapshots, capacity planning475- **[shell-scripting.md](resources/shell-scripting.md)** - Bash scripting patterns, error handling, testing, best practices476477### Windows Administration478- **[windows-administration.md](resources/windows-administration.md)** - Windows Server, Active Directory, GPO, IIS, services, registry, security hardening479- **[powershell-scripting.md](resources/powershell-scripting.md)** - PowerShell fundamentals, scripting, DSC, remote management, best practices480481### Networking482- **[networking-fundamentals.md](resources/networking-fundamentals.md)** - TCP/IP, DNS, load balancers, firewalls, routing, network debugging483- **[security-hardening.md](resources/security-hardening.md)** - OS hardening, CIS benchmarks, firewall, SELinux/AppArmor, SSH, audit logging484485### Performance & Troubleshooting486- **[performance-tuning.md](resources/performance-tuning.md)** - CPU optimization, memory tuning, disk I/O, network performance, profiling tools487- **[troubleshooting-guide.md](resources/troubleshooting-guide.md)** - Debugging methodology, diagnostic tools, common issues, log analysis488489### Automation & Configuration490- **[configuration-management.md](resources/configuration-management.md)** - Ansible playbooks, Chef cookbooks, Puppet manifests, DSC, best practices491- **[automation-patterns.md](resources/automation-patterns.md)** - Cron jobs, systemd timers, Task Scheduler, idempotency, error handling492493### Monitoring494- **[system-monitoring.md](resources/system-monitoring.md)** - Log aggregation, metrics collection, dashboards, alerting, monitoring best practices495496## Best Practices497498### System Administration4995001. **Automation First:**501 - Use configuration management tools502 - Version control all configurations503 - Implement Infrastructure as Code504 - Automate repetitive tasks505 - Document automation procedures5065072. **Security:**508 - Principle of least privilege509 - Regular security updates510 - Implement firewall rules511 - Enable audit logging512 - Use SSH keys, disable password auth5135143. **Monitoring:**515 - Comprehensive system monitoring516 - Centralized logging517 - Proactive alerting518 - Regular performance reviews519 - Capacity planning520521### Configuration Management5225231. **Idempotency:**524 - Ensure scripts can run multiple times safely525 - Check state before making changes526 - Use declarative configurations527 - Test thoroughly before production5285292. **Version Control:**530 - Store all configs in Git531 - Use branches for testing532 - Tag releases533 - Document changes in commit messages5345353. **Testing:**536 - Test in staging environment537 - Use linters (ansible-lint, shellcheck)538 - Implement smoke tests539 - Rollback procedures ready540541### Performance Optimization5425431. **Measure First:**544 - Baseline performance metrics545 - Identify bottlenecks before optimizing546 - Use profiling tools547 - Monitor after changes5485492. **Incremental Changes:**550 - One change at a time551 - Measure impact552 - Document tuning parameters553 - Rollback if degraded5545553. **Right-Sizing:**556 - Match resources to workload557 - Monitor utilization558 - Scale when needed559 - Avoid over-provisioning560561## Anti-Patterns to Avoid562563❌ **Manual configuration** - Not repeatable, error-prone564❌ **Root login enabled** - Security vulnerability565❌ **No monitoring** - Can't detect issues566❌ **No backups** - Risk of data loss567❌ **Outdated packages** - Security vulnerabilities568❌ **Single point of failure** - No redundancy569❌ **No documentation** - Knowledge silos570❌ **Direct production changes** - Should use config management571❌ **Ignoring logs** - Miss critical information572❌ **No testing** - Changes break production573574## Common Tasks575576### Task: Configure New Linux Server5775781. Initial setup and security hardening5792. Configure firewall rules5803. Set up SSH key authentication5814. Install and configure monitoring agent5825. Configure log forwarding5836. Apply configuration management5847. Install required packages5858. Configure backups5869. Document server in inventory58710. Test and validate588589### Task: Troubleshoot Performance Issue5905911. Identify symptoms (slow response, high CPU)5922. Check system metrics (CPU, memory, disk, network)5933. Review logs for errors5944. Identify resource bottleneck5955. Analyze top processes5966. Check for configuration issues5977. Implement fix or optimization5988. Monitor after changes5999. Document root cause and solution600601### Task: Automate with Ansible6026031. Design automation workflow6042. Create inventory file6053. Write playbook and roles6064. Test in development environment6075. Use ansible-lint for validation6086. Test in staging environment6097. Document playbook purpose and variables6108. Deploy to production6119. Monitor execution61210. Update runbooks613614## Integration Points615616This skill integrates with:617- **platform-engineering**: Container hosts, Kubernetes nodes, infrastructure automation618- **devsecops**: Security scanning, hardening, compliance checks619- **sre**: System reliability, performance optimization, incident response620- **cloud-engineering**: Cloud VM management, networking, hybrid cloud621- **release-engineering**: Deployment automation, server provisioning622623## Triggers and Activation624625This skill activates when you:626- Work with Linux systems or servers627- Configure networking or firewalls628- Write shell scripts or automation629- Troubleshoot system issues630- Tune performance or optimize resources631- Implement configuration management (Ansible, Chef, Puppet)632- Set up monitoring or logging633- Manage storage or file systems634635## Next Steps636637For your specific task:6381. Identify the systems engineering requirements6392. Review relevant patterns and best practices6403. Choose appropriate tools and automation approach6414. Implement with configuration management6425. Test thoroughly in non-production6436. Monitor and iterate based on feedback644645---646647**Total Resources:** 10 detailed guides covering all aspects of systems engineering648**Pattern Library:** 100+ production-tested patterns for Linux administration and automation649**Maintained by:** Systems Engineering team based on real-world production experience