Get in Touch
 Duration 21 hours

Course Outline

Day 1
Module 1: Introduction to Python for Unix Users

Topics
The case for Python in scripting and automation
• Benefits of using Python for scripting
• Applications of Python in system administration and DevOps

Comparing Bash and Python
• Variables
• Control flow structures (if, loops)
• File handling
• Execution of system commands

Anatomy of a Python script
• Executing Python scripts
• Utilizing the interpreter
• Handling command line arguments
• Introduction to argparse

Exercises
Exercise 1 – Translating a simple Bash script to Python
A Bash script that:
• Lists files within a directory
• Filters by extension
• Displays statistics
Participants will rewrite this script in Python.

Exercise 2 – Python script with CLI arguments
Developing a Python script that:
• Accepts parameters from the command line
• Processes files
• Displays structured results

Module 2: File and Directory Manipulation

Topics
Interacting with the filesystem in Python
• Reading and writing files
• Navigating directories
• Managing paths

Utilizing the pathlib module
• Path management
• File operations

Replacing Unix utilities
• grep
• find
• sed
• awk
via Python implementations

Exercises
Exercise 1 – Filesystem scanning
A Python script that:
• Searches for large files
• Identifies outdated files
• Generates a report

Exercise 2 – Processing configuration files
A Python script that:
• Reads text files
• Extracts relevant data
• Generates statistics

Day 2
Module 3: Log Processing and Text Manipulation

Topics
Handling text in Python
• String operations
• Filtering and transforming data

Regular expressions (regex)
• Pattern matching
• Log parsing

Replacing shell pipelines
Example:
grep | awk | sed | sort
Implemented in Python

Exercises
Exercise 1 – Log file analysis
A Python script that:
• Reads system logs
• Identifies errors
• Calculates error frequency

Exercise 2 – Converting a shell pipeline to Python
Transforming a complex Bash pipeline into a Python script

Module 4: Automating System Commands

Topics
Executing shell commands from Python
• The 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 system commands
A script that:
• Executes Unix commands
• Captures output
• Generates reports

Exercise 2 – Service monitoring
A Python script that:
• Checks service status
• 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
• Data collection from external services
• Integration with existing tools
• Infrastructure scripting

Exercises
Exercise 1 – Python script consuming an API
A script that:
• Collects data from an API
• Processes the information
• Generates a report

Exercise 2 – Automating data collection
A Python script that:
• Gathers 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 develop a CLI automation tool in Python that:
• Analyses log files
• Identifies errors
• Generates statistics
• Can be executed from the command line

Course Outcomes
Upon completing the course, participants will be able to:
• Transform shell scripts into Python scripts
• Utilize 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
  • Proficiency with command line usage (shell/Bash)
  • Practical experience in writing basic shell scripts (e.g., loops, conditions, file operations)
  • A general grasp of system administration concepts is advantageous
  • No prior Python experience is necessary

Target Audience

  • System administrators operating in Unix/Linux environments
  • DevOps engineers aiming to enhance their automation capabilities
  • Engineers and technical specialists who rely on shell scripting for daily operations
  • IT professionals eager to migrate from Bash to Python
  • Developers in Unix environments seeking to automate workflows more efficiently

Number of participants


Price per participant (excl. VAT)

Testimonials (2)

Upcoming Courses

Related Categories