WSL
kubectl
troubleshooting
terminal
command-line

kubectl not found in WSL terminal

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

If WSL says kubectl: command not found, the problem is usually simple: kubectl is either not installed inside the Linux environment or it is installed somewhere that is not on PATH. The most important thing to remember is that WSL has its own shell environment. A tool being installed in Windows does not automatically make it available as a native Linux command in WSL.

First Check Whether It Exists

Start with the simplest diagnostics.

bash
which kubectl
kubectl version --client

If which kubectl prints nothing, the shell cannot find the executable. That means one of two things:

  • 'kubectl is not installed in WSL'
  • it is installed, but not in a directory listed in PATH

Understand the WSL Boundary

A common source of confusion is that Docker Desktop, kubectl, or other tools may be installed on Windows while your WSL shell is a separate Linux environment.

That means this situation is possible:

  • 'kubectl works in PowerShell'
  • 'kubectl is missing in Ubuntu under WSL'

Those are not contradictory. They are different environments.

Install kubectl in WSL

The cleanest fix is usually to install the Linux kubectl binary inside WSL itself.

One common approach is:

bash
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Then verify:

bash
kubectl version --client

Installing it directly in WSL is usually better than trying to call a Windows executable from Linux command aliases.

Check the PATH

If the binary exists but still is not found, print the current path.

bash
echo "$PATH"

A working installation directory such as /usr/local/bin should appear there. If it does not, update your shell configuration.

For example, in .bashrc or .zshrc:

bash
export PATH="$PATH:/usr/local/bin"

Then reload the shell:

bash
source ~/.bashrc

If You Are Using Docker Desktop Integration

Some setups rely on Docker Desktop and Kubernetes integration from Windows, but that still does not guarantee kubectl is present inside WSL. Kubernetes might be running fine while the WSL shell still lacks the CLI.

So separate these questions clearly:

  • is the cluster available?
  • is kubectl installed in WSL?

Do not assume one proves the other.

Check the Kubeconfig Too

Once kubectl is found, the next failure may be configuration rather than installation. A working command path does not guarantee a working cluster connection.

Useful checks:

bash
kubectl config get-contexts
kubectl config current-context

If kubectl exists but cannot find your cluster, the next step is kubeconfig setup rather than command installation.

A Practical Rule

Use a native Linux kubectl inside WSL whenever possible. It is simpler, more predictable, and easier to document.

Trying to bridge to the Windows executable is usually a workaround, not the clean fix.

Common Pitfalls

  • Assuming a Windows installation of kubectl automatically makes the command available inside WSL.
  • Debugging Kubernetes cluster access before confirming the executable exists in WSL at all.
  • Installing kubectl into a directory that is not on the Linux shell PATH.
  • Confusing command-not-found errors with kubeconfig or cluster-authentication problems.
  • Using fragile cross-environment aliases instead of installing the Linux binary directly.

Summary

  • 'kubectl: command not found in WSL usually means missing installation or incorrect PATH inside Linux.'
  • WSL and Windows do not share command discovery automatically.
  • The cleanest fix is to install the Linux kubectl binary inside WSL.
  • After installation, verify both the executable path and the kubeconfig context.
  • Separate environment problems from cluster-configuration problems while debugging.

Course illustration
Course illustration

All Rights Reserved.