AI for sysadmins: practical tools for managing Linux, Windows, and networks
How a sysadmin actually uses AI every day: generating Bash/PowerShell scripts, reading logs, writing documentation, troubleshooting. Tested tools, real-world cases.
Published: June 3, 2025
That Bash script that took you 40 minutes — checking disk space across 30 hosts, email alerts, SSH timeout handling — an AI would have written it in 45 seconds. This isn’t the future of IT. It’s what you can do today, for free or close to it.
Bash and PowerShell scripts: paste this into your prompt
The trick isn’t asking “write a script that checks disk usage.” It’s giving precise context.
Bash prompt:
Write a Bash script that connects via SSH to a list of hosts (from
hosts.txt, one per line), checks the disk usage percentage on every mounted partition, and sends an alert viamailxif anything goes above 80%. Handle SSH timeouts (ConnectTimeout=5). Must run without user interaction.
You get 60–80 working lines: a loop over the file, timeouts, a formatted email body, error handling. Don’t copy it blindly — read it — but 90% of the work is done.
Prompt for PowerShell + Active Directory:
Write a PowerShell script that finds all AD user accounts with an expired password or one set to “never expires”, and exports a CSV with: SamAccountName, DisplayName, LastLogonDate, PasswordLastSet, PasswordNeverExpires. Enabled users only.
The AI knows Get-ADUser, the ActiveDirectory modules, the right parameters. It saves you 20 minutes of Microsoft documentation.
Rule: the more context you give, the better it works. Specify OS, distro, PowerShell version, available tools (“I only have curl, not wget”), what it should do on error. Lazy prompt = generic script.
Logs and troubleshooting: paste and ask
You’ve got this in dmesg on Ubuntu 22.04:
kernel: BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
kernel: Call Trace: nvme_irq+0x3d/0x120 [nvme]
Prompt:
This is a kernel panic from Ubuntu 22.04 with NVMe storage. What’s the cause and what are the steps to diagnose it?
The AI identifies the nvme driver, explains the null pointer in the interrupt handler, points you to dmesg | grep nvme, firmware updates, and checking the kernel against known bugs. It’s not infallible, but it’s a solid starting point instead of an hour on Stack Overflow.
It also works for Nginx: paste 50 lines of error.log with upstream timed out and Connection refused. It distinguishes timeouts (slow backend) from connection refused (backend down or wrong port), tells you where to look and how to set proxy_connect_timeout.
Documentation nobody ever writes
You have a PostgreSQL backup script that’s been running for 3 years with no README. Paste it and ask:
Generate an operational runbook in Markdown: description, prerequisites, configuration variables, how to run it manually, how to interpret the logs, what to do if it fails.
From 2 hours down to 20 minutes. Same thing with docker-compose.yml: paste it, ask for documentation of the architecture, ports, volumes, environment variables, deployment on a new server.
It also works for reviewing configurations before deploying: nginx.conf, Dockerfile, sshd_config, iptables rules. It doesn’t replace a security audit, but it catches the obvious things that sometimes slip through — PermitRootLogin yes, overly broad NOPASSWD, non-optimized Docker layers.
Tools: what I use
ChatGPT / Claude.ai (free or $20/month): for spot questions, logs, quick scripts. Great to get started.
Ollama (free, local): install models like llama3.1 or codellama on your own hardware. Zero cloud, zero data leaving your network. Requires 16GB RAM and a decent GPU for capable models.
curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.1
ollama run llama3.1
Claude Code ($20/month Max or pay-per-use API): a terminal agent that reads real files on your filesystem, edits scripts, runs commands. Useful if you work on complex codebases or configurations.
Core security rule: never paste passwords, API keys, private SSH keys, personal data, database dumps, or env output into a cloud AI. If you need to analyze logs with sensitive data, anonymize them first or use Ollama locally.
What to do
- Take a script you need to write this week. Describe it to ChatGPT or Claude with a detailed prompt. Observe, adapt, keep the result.
- Install Ollama on an internal server with a GPU — you get a free local AI for daily tasks.
- Pick a piece of undocumented infrastructure and ask for a runbook. Put the result in the internal repo.