Key Python Components for System Administration
os: Interact with the operating system, such as executing commands or modifying the filesystem.
shutil: Offers file operations such as copying, moving, and file removal.
subprocess: For running and managing external processes.
System Administration Use Cases
Managing the File System
shutil is your go-to for high-level file operations.
The os module has methods for directory and file-based tasks, like listing directories or checking file existence.
Working with Processes
You can create, manage, and communicate with system processes using the subprocess module.
Networking and Services
Need to interact with networks or manage services like those started with systemd? Use libraries like request, urllib, or paramiko for network tasks.
User and Permissions Management
Control access to resources using modules like pwd, grp, and os
Script Design Tips
Aim for reliability and compatibility across systems.
Use clear error handling.
Validate user inputs and handle permissions appropriately.
Avoid hardcoding credentials and sensitive data.
Where possible, consider concurrent safety using locks or database transactions.
Add in some practical exercises, building some automation.
Do what the front says, DO IT