Course Outline
Day 1
Module 1: Getting Started with Python for Unix Users
Key Topics
The rationale for using Python in scripting and automation
• The benefits of Python for scripting tasks
• Applying Python in system administration and DevOps contexts
Comparing Bash and Python
• Variables
• Control flow structures (if statements, loops)
• File handling techniques
• Executing system commands
Anatomy of a Python script
• Executing Python scripts
• Utilizing the interpreter
• Handling command-line arguments
• An introduction to the argparse module
Practical Exercises
Exercise 1 – Translating a basic Bash script to Python
A Bash script that:
• Lists files within a directory
• Filters based on extension
• Displays statistical information
Participants will recreate this functionality in Python.
Exercise 2 – Python scripting with CLI parameters
Developing a Python script that:
• Accepts parameters from the command line
• Processes files
Module 2: Managing Files and Directories
Key Topics
Interacting with the file system in Python
• Reading and writing files
• Navigating directory structures
• Handling file paths
Leveraging the pathlib module
• Path management strategies
• Performing file operations
Substituting standard Unix utilities
• grep
• find
• sed
• awk
Implementing these functions using Python
Practical Exercises
Exercise 1 – File system exploration
A Python script that:
• Locates large files
• Identifies old files
• Compiles a report
Exercise 2 – Analyzing configuration files
A Python script that:
• Reads text files
Day 2
Module 3: Processing Logs and Manipulating Text
Key Topics
Text handling in Python
• String operations
• Filtering and transforming data
Regular expressions (regex)
• Pattern recognition
• Log parsing techniques
Replacing complex shell pipelines
Example:
grep | awk | sed | sort
Replicated in Python
Practical Exercises
Exercise 1 – Log file examination
A Python script that:
• Ingests system logs
• Detects errors
• Computes error frequency
Exercise 2 – Migrating a shell pipeline to Python
Converting a complex Bash pipeline into an equivalent Python script
Module 4: Automating System Commands
Key Topics
Running shell commands via Python
• The subprocess module
• Capturing output
• Managing errors
Automating administrative duties
• Executing system commands
• Integration with cron jobs
• Scripting for repetitive tasks
Process management
• Monitoring active processes
• Basic parallel execution
Practical Exercises
Exercise 1 – Python-driven system command execution
A script that:
• Runs Unix commands
• Captures the output
• Generates reports
Exercise 2 – Service monitoring
A Python script that:
• Verifies service status
• Collects relevant data
• Displays results
Day 3
Module 5: Advanced Automation and External Service Integration
Key Topics
Interacting with APIs in Python
• Introduction to HTTP requests
• Authentication and token management
• Handling JSON responses
Python for DevOps automation
• Gathering data from external services
• Integrating with existing tools
• Infrastructure scripting
Practical Exercises
Exercise 1 – Consuming APIs with Python
A script that:
• Retrieves data from an API
• Processes the information
• Produces a report
Exercise 2 – Automating data collection
A Python script that:
• Aggregates system information
• Creates JSON or CSV reports
Module 6: Developing a CLI Tool for Administration
Key Topics
Structuring a Python project
• Code organization
• Reusing functions
• Modules and packages
Building a CLI tool
• Command-line argument handling
• Structured output formats
• Error management
Capstone Project
Participants will construct a CLI automation tool in Python capable of:
• Analyzing log files
• Identifying errors
• Generating statistics
• Running directly from the command line
Learning Outcomes
Upon completion of the course, participants will be able to:
• Convert shell scripts into Python scripts
• Utilize Python for automating system tasks
• Process logs and complex datasets
• Build CLI tools for Unix system administration
Requirements
Prerequisites
- Foundational knowledge of Unix/Linux operating systems
- Proficiency in command-line usage (shell/Bash)
- Experience in writing basic shell scripts (e.g., loops, conditions, file operations)
- A general grasp of system administration concepts is advantageous
- No previous experience with Python is necessary
Target Audience
- System administrators operating within Unix/Linux environments
- DevOps engineers aiming to refine their automation capabilities
- Engineers and technical specialists who rely on shell scripting for routine tasks
- IT professionals eager to transition from Bash to Python
- Developers working in Unix settings who seek to automate workflows more effectively
Testimonials (2)
everything was perfect
Florin Vrincianu
Course - Python Programming Fundamentals
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.