---
title: "Execute an adb shell command on an Android device"
method: POST
path: "/sessions/{sessionId}/device/executeShellCommand"
tags: ["Device Interactions"]
---

# Execute an adb shell command on an Android device

`POST /sessions/{sessionId}/device/executeShellCommand`

## Request

- Base URL: `https://api.us-west-1.saucelabs.com/rdc/v2`
- URL: `https://api.us-west-1.saucelabs.com/rdc/v2/sessions/{sessionId}/device/executeShellCommand`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/docs/sessions/:sessionId/device/executeShellCommand/post.ts> (a function with typed inputs; its response is checked against the schema)

Runs an adb shell command on the device and returns stdout. This command is not available for iOS devices.
The adbShellCommand should be the shell command without the 'adb shell' prefix (e.g., 'ls /' not 'adb shell ls /').
Use for checking device properties, listing packages, granting permissions, or any operation available through adb.

On a private device any adb shell command runs. On a public device, which is shared infrastructure, commands are
restricted to an allowlist and anything outside it comes back as a `400`. The allowlist is published in the
[mobile FAQ](https://docs.saucelabs.com/mobile-apps/mobile-faq/#im-encountering-errors-when-executing-adb-shell-commands-what-could-be-the-issue).

## Path parameters

- `sessionId` string, required

## Request body

- object
  - `adbShellCommand` string, required: The shell command to execute on the device. Note: you do not need to prefix your command with 'adb shell' to run.

## Response `200`

Command executed successfully

- object
  - `stdout` string: The stdout of your shell command.

## Other responses

- `400`: The request was rejected, or the command is not on the allowlist that applies to public devices.
- `404`: Not Found
- `502`: Temporary network error while proxying adb shell command to device.
- `504`: Timeout occurred while proxying adb shell command to device.

---

[API](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference.md) - [All operations](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/revisions/f845a4b66e37?raw)
