System & processes¶
The os module manages host environments, process contexts, and shell command execution. Scripts use it to query system information, manipulate environment variables, and run external commands as sub-processes.
To explore specific topics, select one of the following sections:
- Launching processes: Execute local commands, manage timeouts, environments, and handle execution results.
- Process context: Inspect host names, user profiles, working directories, and process IDs.
- Security: Understand the security model, permission profiles, and gVisor sandbox integration for executing system operations.
Quickstart Example¶
The following script queries basic host details and runs a shell command:
def main():
# Query basic host and user context
print("Host:", os.hostname())
print("User:", os.user.name)
# Execute a simple local command
info = os.exec("uname -a")
print("OS Info:", info.strip())