Course Outline
Day 1
Module 1: Introduction to Python for Unix Users
Topics
Rationale for Using Python in Scripting and Automation
• advantages of Python for scripting
• application of Python in system administration and DevOps
Comparison: Bash vs Python
• variables
• control flow (if statements, loops)
• file handling
• execution of system commands
Structure of a Python Script
• execution of Python scripts
• utilization of the interpreter
• command line arguments
• introduction to argparse
Exercises
Exercise 1 – Converting a Simple Bash Script to Python
Rewrite a Bash script that:
• lists files from a directory
• filters by file extension
• displays statistical data
Participants will rewrite this script in Python.
Exercise 2 – Python Script with CLI Arguments
Develop a Python script that:
• accepts parameters from the command line
• processes files
• outputs structured results
Module 2: File and Directory Manipulation
Topics
Working with the Filesystem in Python
• reading and writing files
• navigating directories
• managing paths
Using the pathlib Module
• path management
• file operations
Replacing Unix Utilities with Python
• grep
• find
• sed
• awk
Implementations in Python
Exercises
Exercise 1 – Filesystem Scanning
Develop a Python script that:
• searches for large files
• identifies older files
• generates a report
Exercise 2 – Processing Configuration Files
Develop a Python script that:
• reads text files
• extracts relevant information
• generates statistics
Day 2
Module 3: Log Processing and Text Manipulation
Topics
Working with Text in Python
• string operations
• filtering and transforming data
Regular Expressions (regex)
• pattern identification
• log parsing
Replacing Shell Pipelines
Example:
grep | awk | sed | sort
Implemented in Python
Exercises
Exercise 1 – Log File Analysis
Develop a Python script that:
• reads system logs
• identifies errors
• calculates error frequency
Exercise 2 – Converting a Shell Pipeline to Python
Transform a complex Bash pipeline into a Python script
Module 4: Automating System Commands
Topics
Executing Shell Commands from Python
• subprocess module
• capturing output
• error handling
Automating Administrative Tasks
• running system commands
• integration with cron jobs
• scripting for repetitive tasks
Process Management
• monitoring processes
• simple parallel execution
Exercises
Exercise 1 – Python Script for Running System Commands
Develop a script that:
• runs Unix commands
• captures output
• generates reports
Exercise 2 – Service Monitoring
Develop a Python script that:
• checks the status of a service
• collects information
• displays results
Day 3
Module 5: Advanced Automation and Interaction with External Services
Topics
Working with APIs in Python
• introduction to HTTP requests
• authentication and tokens
• processing JSON responses
Python for DevOps Automation
• collecting data from external services
• integration with existing tools
• infrastructure scripting
Exercises
Exercise 1 – Python Script Consuming an API
Develop a script that:
• collects data from an API
• processes the information
• generates a report
Exercise 2 – Automating Data Collection
Develop a Python script that:
• collects system information
• generates a JSON or CSV report
Module 6: Building a CLI Tool for Administration
Topics
Structuring a Python Project
• code organization
• function reuse
• modules and packages
Creating a CLI Tool
• command line arguments
• structured output
• error handling
Final exercise
Participants will build a CLI automation tool in Python that:
• analyzes log files
• identifies errors
• generates statistics
• can be executed from the command line
Course Outcomes
By the end of the course, participants will be able to:
• transform shell scripts into Python scripts
• use Python for automating system tasks
• process logs and complex data
• build CLI tools for Unix system administration
Requirements
Prerequisites
- Foundational knowledge of Unix/Linux operating systems
- Familiarity with command line usage (shell/Bash)
- Experience in writing basic shell scripts (e.g., loops, conditions, file operations)
- A general understanding of system administration concepts is advantageous
- No prior experience with Python is required
Target Audience
- System administrators operating in Unix/Linux environments
- DevOps engineers seeking to enhance their automation capabilities
- Engineers and technical specialists who rely on shell scripting for daily tasks
- IT professionals interested in transitioning from Bash to Python
- Developers working in Unix environments who wish to streamline their workflow automation
Testimonials (2)
Hands-on exercises related to content really helps to understand more about each topic. Also, style of start class with lecture and continue with hands-on exercise is good and helpful to relate with the lecture that presented earlier.
Nazeera Mohamad - Ministry of Science, Technology and Innovation
Course - Introduction to Data Science and AI using Python
Examples/exercices perfectly adapted to our domain