Installing kubectl on Linux - The Quick Way

Installing kubectl on Linux

Control your Kubernetes cluster from the command line

📅 October 21, 2025 | ⏱️ 2 min read | 🏷️ Kubernetes, kubectl, DevOps

Need to manage a Kubernetes cluster? You'll need kubectl. It's the command-line tool that lets you deploy apps, inspect resources, and basically do everything you need with Kubernetes.

Installing it on Linux takes about a minute. Let's do it.

What You Need

  • Any Linux distribution
  • curl installed
  • Sudo access

The Installation

Step 1: Download kubectl

This command downloads the latest stable version:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

That nested curl command automatically grabs the latest stable version number, so you always get the current release.

Step 2: Make It Executable

The downloaded file needs execute permissions:

chmod +x ./kubectl

Step 3: Move It to Your PATH

Put kubectl somewhere your system can find it:

sudo mv ./kubectl /usr/local/bin

Now kubectl is available system-wide.

Step 4: Verify Installation

Check that it's working:

kubectl version --client

You should see the version info. That means kubectl is installed and ready.

Note: The --short flag is deprecated in newer versions, so we use --client instead.

All Commands Together

Copy-paste the whole thing:

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 kubectl version --client

Four commands. Done.

Connect to a Cluster

kubectl is installed, but it needs a cluster to talk to. If you already have a cluster, you'll need a kubeconfig file (usually at ~/.kube/config).

Test your connection:

kubectl cluster-info

If you see cluster details, you're connected. If not, you need to configure your kubeconfig file first.

No cluster yet? You can set up a local one with minikube or kind for testing. Or if you're using a cloud provider like AWS EKS or Google GKE, they'll give you the kubeconfig file.

Quick Commands to Try

Once you're connected, try these:

# See all pods kubectl get pods # See all services kubectl get services # See all namespaces kubectl get namespaces

Enable Autocomplete

Want to make kubectl easier to use? Enable shell completion. For bash:

echo 'source <(kubectl completion bash)' >> ~/.bashrc source ~/.bashrc

Now you can press Tab to autocomplete kubectl commands. Saves a ton of typing.

Pro tip: Create an alias to save even more time: alias k=kubectl. Now you can just type k get pods instead.

That's It

kubectl is installed and ready to go. Now you can manage your Kubernetes workloads from the command line. Check out the official Kubernetes docs for more commands and examples.

Happy clustering! ☸️

Written by someone who types kubectl way too often | 2025

Comments

Popular posts from this blog