Course Outline
Day 1
Module 1: Introduction to Python for Unix Users
Topics
Why Python for scripting and automation
• Advantages of Python for scripting
• Utilizing Python in system administration and DevOps
Bash vs Python comparison
• Variables
• Control flow (if, loops)
• Working with files
• Executing system commands
Structure of a Python script
• Running Python scripts
• Using the interpreter
• Command line arguments
• Introduction to argparse
Exercises
Exercise 1 – Converting a simple Bash script to Python
A Bash script that:
• Lists files from a directory
• Filters by extension
• Displays statistics
Participants will rewrite the script in Python.
Exercise 2 – Python script with CLI arguments
Creating a Python script that:
• Receives parameters from the command line
• Processes files
• Displays structured results
Module 2: File and Directory Manipulation
Topics
Working with the filesystem in Python
• Reading and writing files
• Navigating directories
• Handling paths
Using the pathlib module
• Path management
• File operations
Replacing Unix utilities
• grep
• find
• sed
• awk
with Python implementations
Exercises
Exercise 1 – Filesystem scanning
Python script that:
• Searches for large files
• Identifies old files
• Generates a report
Exercise 2 – Processing configuration files
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
Python script that:
• Reads system logs
• Identifies errors
• Calculates error frequency
Exercise 2 – Converting a shell pipeline to Python
Complex Bash pipeline transformed 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 that runs system commands
Script that:
• Runs Unix commands
• Captures output
• Generates reports
Exercise 2 – Service monitoring
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
Script that:
• Collects data from an API
• Processes the information
• Generates a report
Exercise 2 – Automating data collection
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 organisation
• 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:
• Analyses log files
• Identifies errors
• Generates statistics
• Can be run 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
- Fundamental knowledge of Unix/Linux operating systems
- Familiarity with command-line usage (shell/Bash)
- Experience writing simple shell scripts (e.g., loops, conditions, file operations)
- A general understanding of system administration concepts is advantageous
- No prior Python experience is required
Target Audience
- System administrators working within Unix/Linux environments
- DevOps engineers seeking to enhance their automation capabilities
- Engineers and technical specialists utilizing shell scripting for daily tasks
- IT professionals interested in transitioning from Bash to Python
- Developers working in Unix environments who wish to automate workflows more efficiently
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