Install kubectl on Ubuntu 22.04 using bash

M Ferreira
M Ferreira

Getting started with Kubernetes you will need kubectl command line tool.

1. Install kubectl binary

This command will bring down the latest version.

curl -LO "$(curl -L -s"

If you want a specific version do:

curl -LO "$(curl -L -s"

Validate the binary

You should validate your download by using the checksum file, get it here:

curl -LO "$(curl -L -s"

Validate the kubectl binary agains the checksum file:

echo "$(cat kubectl.sha256) kubectl" | sha256sum --check

If ok it should output:

kubectl: OK

If it failed for some reason sha256 exits with nonzero status and outputs:

kubectl: FAILED sha256sum: WARNING: 1 computed checksum did NOT match

Check you URL and try again.

3. Finally Install kubectl

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Command downloads the binary to you local bin to a folder called kubectl with the required permissions.

Chmod owner

✅ Owner can read

✅ Owner can write

✅ Owner can execute

Chmod group

✅ Group can read

❌ Group can't write

✅ Group can execute

Chmod other

✅ Others can read

❌ Others can't write

❌ Others can execute

4. Check to ensure all went well

kubectl version


Client Version: v1.25.4 Kustomize Version: v4.5.7 Error from server (NotFound): the server could not find the requested resource

Stay up to date

Consider keeping up to date with software development and design by signing up to my newsletter.

I will only email you when I make a new post.