Get in Touch

Course Outline

Day 1
Module 1: Introduction to Python for Unix Users

Topics
Why choose Python for scripting and automation?
• Advantages of Python for scripting tasks
• Utilizing Python in system administration and DevOps contexts

Comparison of Bash and Python
• Variables
• Control flow structures (if statements, loops)
• File handling
• Executing system commands

Structure of a Python script
• Running Python scripts
• Utilizing the interpreter
• Managing command-line arguments
• Introduction to the argparse library

Exercises
Exercise 1 – Converting a basic Bash script to Python
The Bash script performs the following:
• Lists files within a directory
• Filters files by extension
• Displays statistical data
Participants will rewrite this functionality in Python.

Exercise 2 – Python script utilizing CLI arguments
Creating a Python script that:
• Accepts parameters from the command line
• Processes specified files
• Outputs structured results

Module 2: File and Directory Manipulation

Topics
Navigating the filesystem in Python
• Reading and writing files
• Directory navigation
• Path manipulation

Utilizing the pathlib module
• Path management techniques
• Performing file operations

Replacing standard Unix utilities
• grep
• find
• sed
• awk
with equivalent Python implementations

Exercises
Exercise 1 – Filesystem scanning
Python script that:
• Locates large files
• Identifies outdated files
• Generates a summary report

Exercise 2 – Processing configuration files
Python script that:
• Reads text-based files
• Extracts pertinent information
• Generates statistical data

Day 2
Module 3: Log Processing and Text Manipulation

Topics
Text handling in Python
• String operations
• Filtering and transforming data

Regular expressions (regex)
• Pattern recognition
• Parsing log data

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

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

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

Module 4: Automating System Commands

Topics
Executing shell commands from within Python
• Using the subprocess module
• Capturing command output
• Implementing error handling

Automating administrative tasks
• Running system commands programmatically
• Integrating with cron jobs
• Scripting for repetitive operations

Process management
• Monitoring active processes
• Implementing simple parallel execution

Exercises
Exercise 1 – Python script executing system commands
Script that:
• Runs Unix commands
• Captures the output
• Generates reports

Exercise 2 – Service monitoring
Python script that:
• Checks service status
• Gathers 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 token management
• Processing JSON responses

Python for DevOps automation
• Collecting data from external services
• Integrating with existing toolsets
• Infrastructure scripting

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

Exercise 2 – Automating data collection
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 organization
• Function reuse
• Modules and packages

Creating a CLI tool
• Handling command-line arguments
• Producing structured output
• Implementing error handling

Final exercise
Participants will construct a CLI automation tool in Python that:
• Analyzes log files
• Identifies errors
• Generates statistics
• Can be executed directly from the command line

Course Outcomes
Upon completion of the course, participants will be able to:
• Transform shell scripts into Python equivalents
• Utilize Python for automating system tasks
• Process logs and complex data structures
• Build CLI tools for Unix system administration

Requirements

Prerequisites

  • Foundational knowledge of Unix/Linux operating systems
  • Familiarity with command-line interfaces (shell/Bash)
  • Experience creating simple shell scripts (e.g., loops, conditional statements, file operations)
  • A general understanding of system administration concepts is advantageous
  • No prior Python experience is necessary

Target Audience

  • System administrators operating within Unix/Linux environments
  • DevOps engineers seeking to enhance their automation capabilities
  • Engineers and technical specialists who rely on shell scripting for daily operations
  • IT professionals interested in migrating from Bash to Python
  • Developers working in Unix environments who wish to streamline their workflow automation
 21 Hours

Number of participants


Price per participant

Testimonials (2)

Upcoming Courses

Related Categories