Basic Usage
The basic syntax for running sandboxec is:The
-- separator is optional but recommended when passing arguments to the wrapped command to avoid ambiguity with sandboxec’s own flags.Command Structure
sandboxec wraps your target command and applies sandbox restrictions before execution:- Parse CLI flags and configuration
- Load and merge configuration from files (if any)
- Apply Landlock restrictions based on rules
- Execute the target command with restrictions inherited by all child processes
- Return the exit code of the wrapped command
Passing Arguments
There are two ways to pass arguments to your wrapped command:Without -- separator
With -- separator (recommended)
-- explicitly marks the end of sandboxec options. Everything after -- is treated as the command and its arguments.
Command-Line Flags
Core Options
Path to YAML configuration file. Can be a local path or HTTP(S) URL.
Named config profile from the sandboxec/profiles repository.
Add filesystem rule. Can be specified multiple times. See Filesystem Rules for details.
Add network rule. Can be specified multiple times. See Network Rules for details.
Advanced Options
Force a specific Landlock ABI version (1-6).
0 means use the highest available version.Continue even if the kernel lacks support for some features. Degrades gracefully instead of failing.
Do not fail if a filesystem rule path does not exist.
Enable scoped IPC restrictions. Requires Landlock ABI v6+.
Automatically add
read_exec rights for host runtime paths and their shared library dependencies.Execution mode:
run or mcp.run: Execute a single command (default)mcp: Start as an MCP server
In
mcp mode, no command arguments are accepted. The MCP server provides an exec tool for running commands.Utility Flags
Show version information and exit.
Show help message and exit.
Exit Codes
sandboxec returns different exit codes based on execution results:The wrapped command succeeded (exited with code 0).
The wrapped command exited with code
N. sandboxec forwards the exit code.sandboxec itself failed (parsing error, configuration error, Landlock failure, missing command, etc.).
Examples
MCP Mode
When running in MCP mode, sandboxec provides a Model Context Protocol server with anexec tool:
Execute a command and return
stdout, stderr, and exit_code.Input parameters:command(required): The command to executeargs(optional): Array of arguments