> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hopx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Commands

> Complete guide to running shell commands in HopX sandboxes - synchronous and background command execution. Learn how to execute shell commands, run system administration tasks, install packages, and automate workflows using Python and JavaScript SDKs or REST API. Includes examples for synchronous and background command execution.

Run shell commands in HopX sandboxes for system administration, package installation, and automation. This hub covers all command execution methods.

## Related

* [CLI Commands](/cli/commands/cmd) - Shell commands from CLI

## What You'll Learn

* How to run shell commands synchronously
* How to run commands in the background
* How to handle command output and errors
* How to use commands for system administration
* How to integrate commands with code execution

## Command Execution Overview

| Execution Mode                                                | SDK Method                          | API Endpoint                |
| ------------------------------------------------------------- | ----------------------------------- | --------------------------- |
| **[Running Commands](/core-concepts/commands/running)**       | `sandbox.commands.run()`            | `POST /commands/run`        |
| **[Background Commands](/core-concepts/commands/background)** | `sandbox.commands.run_background()` | `POST /commands/background` |

## Core Concepts

### Running Commands

Execute shell commands synchronously and wait for results.

* **[Running Commands](/core-concepts/commands/running)** - Run shell commands
* **SDK**: [Python: sandbox.commands.run()](/sdk/python/commands#run) | [JavaScript: sandbox.commands.run()](/sdk/javascript/commands#run)
* **API**: [POST /commands/run](/api/vm-agent/run-command)

### Background Commands

Run long-running commands in the background without blocking.

* **[Background Commands](/core-concepts/commands/background)** - Run commands in background
* **SDK**: [Python: sandbox.commands.run\_background()](/sdk/python/commands#run_background) | [JavaScript: sandbox.commands.runBackground()](/sdk/javascript/commands#runbackground)
* **API**: [POST /commands/background](/api/vm-agent/run-command-background)

## SDK Reference

### Python SDK

Complete reference for Python command execution.

* **[Commands Module](/sdk/python/commands)** - Complete command API
  * `commands.run()` - Run commands synchronously
  * `commands.run_background()` - Run commands in background

### JavaScript SDK

Complete reference for JavaScript/TypeScript command execution.

* **[Commands Module](/sdk/javascript/commands)** - Complete command API
  * `commands.run()` - Run commands synchronously
  * `commands.runBackground()` - Run commands in background

## API Reference

### VM Agent API

REST API endpoints for command execution.

* **[VM Agent API Overview](/api/vm-agent/overview)** - API overview
* **[Run Command](/api/vm-agent/run-command)** - `POST /commands/run` - Run commands synchronously
* **[Run Command Background](/api/vm-agent/run-command-background)** - `POST /commands/background` - Run commands in background

## Quick Start

If you're new to command execution, start here:

1. **[Running Commands](/core-concepts/commands/running)** - Run your first command
2. **[Background Commands](/core-concepts/commands/background)** - Run long-running commands

## Related Topics

* **[Code Execution](/core-concepts/code-execution/synchronous)** - Execute code alongside commands
* **[File Operations](/core-concepts/filesystem/reading)** - Work with files via commands
* **[Environment Variables](/core-concepts/environment/getting)** - Use variables in commands
* **[Process Management](/core-concepts/code-execution/process-management)** - Manage command processes

## Next Steps

* Learn about [Running Commands](/core-concepts/commands/running) for system administration
* Explore [Background Commands](/core-concepts/commands/background) for long-running tasks
* Review [Code Execution](/core-concepts/code-execution/synchronous) to combine with commands
* Check out [Process Management](/core-concepts/code-execution/process-management) for advanced workflows
