Get in Touch

Course Outline

Day 1
Module 1: Introduction to Python for Unix Users

Topics
Strategic rationale for adopting Python in scripting and automation
• Key advantages of Python for operational scripting
• Application of Python in system administration and DevOps environments for government operations

Comparative analysis of Bash and Python capabilities
• Variable management
• Control flow structures (conditional statements, loops)
• File handling protocols
• Execution of system-level commands

Architectural components of a Python script
• Execution methods for Python scripts
• Utilization of the interpreter
• Command-line argument processing
• Foundational use of the argparse module

Exercises
Exercise 1 – Conversion of a basic Bash script to Python
Refactoring a Bash script that performs the following functions:
• Enumeration of files within a directory
• Filtering based on file extensions
• Generation of statistical data
Participants will rewrite the script in Python to ensure maintainability and clarity.

Exercise 2 – Development of a Python script with CLI parameters
Creation of a Python script that:
• Ingests parameters via the command line
• Processes designated files
• Outputs structured results for review

Module 2: File and Directory Manipulation

Topics
Filesystem interaction within the Python environment
• Data reading and writing procedures
• Directory navigation techniques
• Path management standards

Implementation of the pathlib module
• Robust path management
• Execution of file operations

Substitution of standard Unix utilities with Python
• grep
• find
• sed
• awk
• Python-based implementations for enhanced control and readability

Exercises
Exercise 1 – Filesystem scanning and auditing
Development of a Python script that:
• Identifies large files for resource optimization
• Detects aged files for archival or deletion
• Produces a comprehensive audit report

Exercise 2 – Configuration file processing
Development of a Python script that:
• Parses text-based configuration files
• Extracts critical configuration data
• Generates statistical summaries for analysis

Day 2
Module 3: Log Processing and Text Manipulation

Topics
Text data handling in Python
• String manipulation techniques
• Data filtering and transformation workflows

Application of Regular Expressions (regex)
• Pattern recognition and identification
• Advanced log parsing techniques

Replacement of complex shell pipelines with Python
Example transformation:
grep | awk | sed | sort
implemented as a unified Python process for improved maintainability

Exercises
Exercise 1 – System log analysis
Development of a Python script that:
• Ingests system log data
• Identifies error patterns
• Calculates error frequency metrics

Exercise 2 – Conversion of a shell pipeline to Python
Transformation of a complex Bash pipeline into a modular Python script for enhanced readability and debugging capabilities

Module 4: Automating System Commands

Topics
Execution of shell commands from within Python
• Utilization of the subprocess module
• Capture and handling of command output
• Comprehensive error management protocols

Automation of administrative workflows
• Execution of recurring system commands
• Integration with cron scheduling for automated task execution
• Scripting for repetitive operational tasks

Process supervision and management
• Monitoring of active processes
• Implementation of simple parallel execution strategies

Exercises
Exercise 1 – Development of a system command executor
Creation of a script that:
• Executes specific Unix commands
• Captures and logs output
• Generates operational reports

Exercise 2 – Service status monitoring
Development of a Python script that:
• Verifies the operational status of system services
• Collects relevant diagnostic information
• Displays consolidated results for assessment

Day 3
Module 5: Advanced Automation and Interaction with External Services

Topics
Integration of Python with Application Programming Interfaces (APIs)
• Introduction to HTTP request protocols
• Authentication mechanisms and token management
• Parsing and processing JSON responses

Python for DevOps and infrastructure automation for government systems
• Data acquisition from external service endpoints
• Integration with established operational tooling
• Infrastructure-as-Code scripting techniques

Exercises
Exercise 1 – API consumption and data retrieval
Development of a script that:
• Retrieves data from a designated API
• Processes and validates the information
• Generates a structured report

Exercise 2 – Automated data collection workflows
Development of a Python script that:
• Collects system environment data
• Generates standardized JSON or CSV reports for archival

Module 6: Building a CLI Tool for Administration

Topics
Structural best practices for Python projects
• Code organization and modularity
• Reuse of functional components
• Management of modules and packages

Development of a Command-Line Interface (CLI) tool
• Robust command-line argument parsing
• Generation of structured output
• Implementation of resilient error handling

Final exercise
Participants will engineer a CLI automation tool in Python that:
• Analyzes log files for compliance and errors
• Identifies and categorizes issues
• Generates statistical insights
• Is executable via the command line for operational use

Course Outcomes
Upon completion of the course, participants will possess the following competencies:
• Conversion of legacy shell scripts into modern Python equivalents
• Application of Python for the automation of system-level tasks
• Processing of logs and complex data structures
• Construction of CLI tools for Unix system administration for government use

Requirements

Prerequisites

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

Target Audience

  • System administrators operating within Unix/Linux environments
  • DevOps engineers seeking to enhance automation capabilities for government infrastructure
  • Engineers and technical specialists utilizing shell scripting for daily operational tasks
  • IT professionals transitioning from Bash to Python for improved maintainability
  • Developers in Unix environments aiming to automate workflows more efficiently and securely
 21 Hours

Number of participants


Price per participant

Testimonials (2)

Upcoming Courses

Related Categories