Run Shell Command
ubuntu_run_commandRun any shell command on a configured Ubuntu server over SSH and get stdout, stderr, and exit code. Use for tasks not covered by specialized system tools.
Instructions
Run an arbitrary shell command on a configured Ubuntu server over SSH and return stdout, stderr, and the exit code.
Prefer the specialized tools when they fit (ubuntu_system_overview, ubuntu_list_services, ubuntu_service_status, ubuntu_check_updates, ubuntu_tail_log) — they produce cleaner output. Use this tool for everything they don't cover.
Args:
server (string): server name from the inventory (see ubuntu_list_servers)
command (string): shell command line; pipes and redirects work
sudo (boolean): run as root via 'sudo -n' — requires passwordless sudo on the server (default false)
timeout_seconds (number): 1-300, default 30
Returns: exit code plus stdout/stderr text, also available as structured content.
Error handling:
Unknown server names return the list of valid names.
A non-zero exit code is NOT a tool error — inspect stderr to understand what the command reported.
If sudo fails with "a password is required", the server lacks passwordless sudo; the output includes the fix.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sudo | No | Run as root via 'sudo -n' (requires passwordless sudo on the server) | |
| server | Yes | Server name from the inventory (see ubuntu_list_servers) | |
| command | Yes | Shell command line to execute; pipes, &&, and redirects are allowed | |
| timeout_seconds | No | Abort if the command runs longer than this (default 30) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | ||
| signal | No | ||
| stderr | Yes | ||
| stdout | Yes | ||
| exit_code | Yes | ||
| capture_truncated | Yes |