# Overview
<subtitle>Run terminal commands in a sandbox. </subtitle>

You can use the `commands.run()` method to run terminal commands inside a sandbox.

```python
from ucloud_sandbox import Sandbox

sandbox = Sandbox.create()
result = sandbox.commands.run('ls -l')
print(result)
```

## Basic usage example

```python
from ucloud_sandbox import Sandbox

sandbox = Sandbox.create()

#Execute command
result = sandbox.commands.run('ls -la /home/user')

# Parse results
if result.exit_code == 0:
    print(f"Success:\n{result.stdout}")
else:
    print(f"Error (Exit {result.exit_code}):\n{result.stderr}")

sandbox.kill()
```

## More features

- [Streaming Output](/docs/agent-sandbox/commands/streaming.md) - Real-time streaming output of stdout and stderr during command execution
- [Run command in background](/docs/agent-sandbox/commands/background.md) - Run a long command in the background and terminate it later
