Last updated:
Kubectl is a command-line tool that lets developers and administrators deploy, monitor, manage, and scale applications in a Kubernetes containerized environment. Having kubectl installed on Ubuntu lets DevOps engineers communicate with different clusters using single-line commands. Cloud engineers often pair it with the AWS CLI on Ubuntu 24.04 to manage hosted clusters.
Quick answer: install kubectl on Ubuntu 26.04 or 24.04 with sudo snap install kubectl --classic (simplest), from the official Kubernetes APT repository (updates with apt upgrade), or as a single binary with curl (you update it yourself). Then run kubectl version --client. Use a kubectl within one minor version of your cluster. As of 16 October 2026 the Kubernetes project maintains releases 1.34 to 1.37, and the official install page uses v1.37 in the APT repository URL.
Ubuntu 26.04 and 24.04: what is different
Nothing in the install steps depends on the Ubuntu release. The Kubernetes APT repository at pkgs.k8s.io is not tied to a distribution codename (the repository line ends in /deb/ /), and the official Kubernetes documentation gives the same Debian-based instructions for every supported release. I could not run these installs on Ubuntu 26.04 for this update because the download hosts (pkgs.k8s.io, dl.k8s.io) are blocked in my test environment, so the steps below follow the official documentation, and the screenshots are from the original Ubuntu 24.04 run.
Update note: the screenshots in the APT method were taken in 2024 with the v1.29 repository. Kubernetes 1.29 no longer receives patches, so use v1.37 (or the minor version your cluster runs) in the commands written in the text. The screenshots otherwise show the same steps.
How to Install kubectl on Ubuntu 26.04 and 24.04
| Method | Command | Auto-updates | Notes |
|---|---|---|---|
| Snap | sudo snap install kubectl --classic |
Yes (snap refresh) | Simplest install |
| APT (Kubernetes repo) | sudo apt-get install -y kubectl (after adding the repository) |
Yes, within the minor version in the repository URL | Full APT integration |
| curl | curl -LO, then sudo install |
No | Pinned to exact version |
Method 1: Install kubectl on Ubuntu 26.04 and 24.04 Using Snap
Step 1: Update Repository
sudo apt update

Step 2: Install Snap Daemon
Snap is not pre-installed on Ubuntu 24.04 minimal installs. Install it if needed:
sudo apt install snapd

Step 3: Install kubectl
The --classic flag gives kubectl full system access required to read kubeconfig files and manage clusters:
sudo snap install kubectl --classic

Step 4: Verify the Installation
sudo kubectl version --client

Uninstall kubectl via Snap
sudo snap remove kubectl

Verify the removal:
sudo kubectl version --client

Method 2: Install kubectl on Ubuntu 26.04 and 24.04 Using APT
This method adds the official Kubernetes APT repository so kubectl receives updates through standard apt upgrade.
Step 1: Update APT Repository
sudo apt-get update

Step 2: Install curl and HTTPS Transport Prerequisites
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg

Step 3: Download the Kubernetes GPG Key
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.37/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Note: If the command fails because the directory does not exist, create it first with sudo mkdir -p /etc/apt/keyrings. The same signing key is used for all Kubernetes repositories, but the version in the repository URL (next step) pins which minor release you get, so change v1.37 to match the Kubernetes minor version your cluster runs.
Step 4: Add the Kubernetes Repository
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.37/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list

Step 5: Update and Install kubectl
sudo apt-get update

sudo apt-get install -y kubectl

The repository URL already limits updates to one minor version. To go further and stop kubectl changing at all during a routine upgrade, pin it (undo with sudo apt-mark unhold kubectl). To move to a newer minor release later, edit /etc/apt/sources.list.d/kubernetes.list, change the version, then run sudo apt-get update and sudo apt-get install -y kubectl:
sudo apt-mark hold kubectl
Step 6: Verify the Installation
kubectl version --client --output=yaml

Uninstall kubectl via APT
sudo apt autoremove kubectl

Verify the removal:
kubectl version --client --output=yaml

Method 3: Install kubectl on Ubuntu 26.04 and 24.04 Using curl
The curl method downloads a specific kubectl binary directly, without adding a package repository. This is useful when you need to pin kubectl to a specific version, similar to how you install Go on Ubuntu 24.04 from a tarball.
Step 1: Install curl
sudo apt install curl

Step 2: Check System Architecture
Use lscpu to confirm your architecture. Download the amd64 binary for x86_64 systems, or substitute arm64 for ARM:

Step 3: Download kubectl
The following command always downloads the latest stable release:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Because this binary is not signed by APT, verify it against the official checksum before running it:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
A response of kubectl: OK means the download is intact. Anything else means you should delete the file and download it again.
Step 4: Make kubectl Executable
chmod +x kubectl

Verify permissions:
ls -al kubectl

Step 5: Move kubectl to Your PATH
sudo mv kubectl /usr/local/bin

Connect kubectl to a cluster
A fresh kubectl install talks to nothing. It reads cluster details from a kubeconfig file at ~/.kube/config, which your cluster provider or administrator supplies. Create the directory and place the file:
mkdir -p ~/.kube
cp /path/to/downloaded-config ~/.kube/config
chmod 600 ~/.kube/config
The chmod 600 step matters — the file holds cluster credentials, and kubectl warns about world-readable configs. To use a config stored elsewhere without overwriting the default, point the environment variable at it instead:
export KUBECONFIG=~/Downloads/my-cluster.yaml
Confirm the connection works. This is the first command that actually contacts the cluster rather than just the local binary:
kubectl cluster-info
kubectl get nodes
Switching between clusters
A single kubeconfig can hold several clusters. Contexts are how you move between them, which is essential once you have separate development and production clusters:
kubectl config get-contexts
kubectl config current-context
kubectl config use-context my-dev-cluster
Enable shell autocompletion
Autocompletion saves a great deal of typing given how long Kubernetes resource names are. Enable it for bash:
sudo apt install bash-completion
echo 'source <(kubectl completion bash)' >> ~/.bashrc
source ~/.bashrc
Many people also add a short alias, then extend completion to it so tab-completion keeps working:
echo 'alias k=kubectl' >> ~/.bashrc
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc
Troubleshooting kubectl on Ubuntu 26.04 and 24.04
| Error | Cause | Fix |
|---|---|---|
| The connection to the server localhost:8080 was refused | No kubeconfig found | Place a valid config at ~/.kube/config or set KUBECONFIG |
| error: You must be logged in to the server (Unauthorized) | Expired or wrong credentials | Refresh the kubeconfig from your provider |
| Unable to connect to the server: dial tcp i/o timeout | Cluster unreachable from this network | Check VPN, firewall, or cluster endpoint |
| WARNING: version difference between client and server exceeds the supported minor version skew | Client too old or too new | Install a kubectl within one minor version of the cluster |
Permission denied on ~/.kube/config |
File owned by root after sudo cp |
sudo chown $(id -u):$(id -g) ~/.kube/config |
The localhost:8080 error is the one most people hit first. It does not mean the install failed — it means kubectl found no cluster configuration and fell back to a default local address that nothing is listening on.
Before using kubectl
Installing kubectl only gives you the Kubernetes command-line client. To manage real workloads, you still need access to a Kubernetes cluster and a valid kubeconfig file. For a remote cluster over SSH, first install OpenSSH Server on Ubuntu 24.04.
Try to keep kubectl close to the Kubernetes cluster version you manage. Kubernetes supports a skew of one minor version in either direction, so a v1.37 client works with clusters from v1.36 to v1.38. Outside that range you may see resources fail to parse or commands behave unexpectedly.