Server Administration: systemd, Nginx & Active Directory
Your desk-side survival guide for managing Linux background services, web reverse proxies, Windows Active Directory domains, and scheduled tasks without breaking production.
Service Lifecycle Anatomy
Almost every Linux service command follows the same 3-part pattern: Manager + Action + Unit.
systemctl status nginx
start / stop controls the service right now.
enable / disable controls whether it starts automatically after a reboot.
Use --now (e.g., systemctl enable --now nginx) to do both at once!
How a web request flows: Nginx faces the internet on ports 80/443 and forwards traffic to your internal systemd app service.
1 Linux systemd & journalctl Commands
systemd is the service manager (PID 1) on modern Linux distributions (Ubuntu, Debian, RHEL, Rocky, Alma). journalctl reads the centralized logs it collects.
sudo systemctl start nginxsudo systemctl stop nginxsudo systemctl restart nginxsudo systemctl reload nginxsudo systemctl enable --now nginxsystemctl status nginxactive (running) in green and the last 10 log lines.
journalctl -u nginx -f-u filters by unit; -f streams new lines in real time (press Ctrl+C to exit).
journalctl -xesystemctl --failed2 Web Servers (Nginx & Apache) Quick Reference
Web servers listen on ports 80 (HTTP) and 443 (HTTPS), serving static files or proxying requests to backend apps.
sudo nginx -tsyntax is ok and test is successful.
sudo systemctl reload nginxnginx -t succeeds to load new server blocks.
sudo apache2ctl configtestsudo httpd -t. Expect Syntax OK.
/etc/nginx/sites-available//etc/nginx/sites-enabled/ to activate.
Port 80 vs Port 443
| Port | Protocol | Encryption | Modern Production Role |
|---|---|---|---|
80 |
HTTP | None (Plaintext) | Used only to issue SSL certs (Let's Encrypt) and immediately 301 redirect to HTTPS. |
443 |
HTTPS | TLS / SSL Encrypted | All live user traffic, logins, and APIs. Required by modern browsers. |
HTTP Status Codes (What Actually Broke?)
| Code | Meaning | Plain-English Diagnosis |
|---|---|---|
| 200 | OK | Everything worked. The server returned the requested page or API response. |
| 301 | Moved Permanently | Permanent redirect (e.g., http:// โ https:// or old URL โ new URL). |
| 403 | Forbidden | Server understood the request but blocked access (check Linux file permissions or Nginx deny rules). |
| 404 | Not Found | File or route doesn't exist at that URL (check root path or typo in URL). |
| 502 | Bad Gateway | Nginx is alive, but the backend app (proxy_pass) is crashed or stopped. Check systemctl status app! |
| 504 | Gateway Timeout | Backend app is running, but took too long to respond (slow DB query or frozen worker). |
3 Windows Server & Active Directory
Essential CMD and PowerShell commands for diagnosing Domain Controllers, Group Policy (GPO), and user/computer accounts.
dcdiaggpupdate /forcegpresult /rGet-ADUser -Identity jdoe -Properties *Get-ADComputer -Filter *-Filter "Name -like 'SRV*'" to find servers quickly.
The 5 FSMO Roles (Flexible Single Master Operations)
While most AD tasks are multi-master, these 5 special roles must be held by only one Domain Controller at a time to prevent conflicts.
| FSMO Role | Scope | What It Does |
|---|---|---|
| Schema Master | Forest-wide (1 per Forest) | Controls updates to the AD blueprint (new attributes/object classes). |
| Domain Naming Master | Forest-wide (1 per Forest) | Approves adding or removing domains in the AD forest. |
| PDC Emulator | Domain-wide (1 per Domain) | Master time source, handles password changes first, and locks out accounts. |
| RID Master | Domain-wide (1 per Domain) | Hands out pools of unique Relative IDs (RIDs) so DCs can create SIDs without duplicates. |
| Infrastructure Master | Domain-wide (1 per Domain) | Updates cross-domain group references (never put on a Global Catalog unless all DCs are GCs). |
4 Cron Jobs & Scheduled Tasks Quick Syntax
Cron runs commands automatically on a schedule. Every standard cron line has 5 time fields followed by the command.
/usr/bin/python3) inside cron!
@reboot /usr/local/bin/start-app.sh0 2 * * * /usr/local/bin/backup.sh0, Hour 2, every day, every month, every weekday.
*/5 * * * * /usr/local/bin/healthcheck.sh*/5 step syntax means "every 5th minute" (0, 5, 10, 15...).
crontab -ecrontab -l to list current scheduled jobs safely without editing.
5 Danger Zone: Production Mistakes to Avoid
systemctl restart instead of reload on live traffic
restart kills all active worker processes and drops in-flight HTTP/API requests. Always prefer sudo systemctl reload nginx for config changes so existing connections finish cleanly.
nginx.conf without running sudo nginx -t first
A single missing semicolon (;) will crash Nginx when you restart it, taking down every website on the server. Always test with nginx -t before reloading.
chmod -R 777 /var/www/html
777 gives every local user and compromised process full read, write, and execute rights. Use 755 for directories and 644 for web files instead.