Python for system administrators

Shell scripts are great until they need a data structure, an error handling strategy or a colleague to maintain them. This course takes what you already do in bash or PowerShell and does it in Python, from rewriting grep and sed to managing a fleet over SSH.

Duration: 3 days · Level: intermediate

For: system administrators, DevOps and network engineers who want to go beyond shell scripts.

Prerequisites: writing basic scripts in bash or PowerShell and being comfortable in a terminal.

Python for system administrators

Day 1 — Python, the admin way

  • Installing Python on servers: good practices
  • Types, conditions and loops, at full speed
  • Functions and modules
  • Exceptions: failing loudly, failing cleanly
  • Reading and writing files
  • Walking the file system with pathlib
  • Copying, moving, archiving with shutil
  • Regular expressions
  • Recreating grep, awk, cut and sed in Python

Day 2 — Talking to the system

  • Parsing logs and counting what matters
  • Dates, durations and time zones without tears
  • Running commands with subprocess
  • Watching processes and resources with psutil
  • Command line arguments with argparse
  • Environment variables
  • Keeping secrets out of scripts with keyring
  • Configuration in JSON, YAML and TOML
  • Generating config files with jinja templates
  • Windows vs Linux: writing portable scripts

Day 3 — Talking to the network

  • Running remote commands over SSH with Fabric and paramiko
  • Querying HTTP APIs with httpx
  • Automating a monitoring or ticketing API
  • Keeping a journal of your scripts with logging
  • Scheduling with cron and systemd timers
  • Single-file scripts with uv inline dependencies
  • Shipping to locked-down machines: WinPython, Nuitka
  • Testing your scripts with pytest

Elevate Your Python Proficiency!