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.
If which kubectl prints nothing, the shell cannot find the executable. That means one of two things:
- '
kubectlis 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:
- '
kubectlworks in PowerShell' - '
kubectlis 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:
Then verify:
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.
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:
Then reload the shell:
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
kubectlinstalled 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:
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
kubectlautomatically makes the command available inside WSL. - Debugging Kubernetes cluster access before confirming the executable exists in WSL at all.
- Installing
kubectlinto a directory that is not on the Linux shellPATH. - 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 foundin WSL usually means missing installation or incorrectPATHinside Linux.' - WSL and Windows do not share command discovery automatically.
- The cleanest fix is to install the Linux
kubectlbinary inside WSL. - After installation, verify both the executable path and the kubeconfig context.
- Separate environment problems from cluster-configuration problems while debugging.

