kubectl exec — Basic UsageIT technician command center
Containers · Docker and Kubernetes

kubectl exec — Basic Usage

Use kubectl exec for a standard administrative task.

Copy-ready commandkubectl exec — Basic Usage
kubectl exec -it -n production pod/web-abc123 -- /bin/sh

Requirements and permissions

Requirements
Docker Engine, Docker Compose, or kubectl
Permissions
Container or cluster permissions vary
Last reviewed
2026-07-31

Examples

Basic Usage

Use kubectl exec for a standard administrative task.

kubectl exec -it -n production pod/web-abc123 -- /bin/sh

Original command

Run a command inside a Kubernetes pod.

kubectl exec -it -n production pod/web-abc123 -- /bin/sh

Common errors

Command not found

Confirm Docker Engine, Docker Compose, or kubectl is installed and available in your current shell.