Objective

Write Python scripts for Linux system administration tasks.

Tools & Technologies

  • Python 3
  • subprocess
  • psutil
  • os

Key Commands

subprocess.run(['systemctl','status','nginx'], capture_output=True)
psutil.disk_usage('/')
shutil.disk_usage('/')
os.getlogin()

Lab Steps

01
subprocess Module

Run shell commands from Python and capture output.

02
psutil

Monitor CPU, memory, disk, and network usage with psutil.

03
File System Ops

Automate file copying, moving, and cleanup operations.

04
System Info Script

Write a script that reports system health metrics.

Challenges Encountered

  • subprocess shell=True is a security risk with user input
  • psutil requires installation — not in stdlib

Key Takeaways

  • Always use subprocess.run() with a list, not shell=True
  • psutil provides cross-platform system monitoring