The kubectl command is an essential part of Kubernetes, and is used to single handedly manage the entire cluster. It provides an interface for administrators to get information about their Kubernetes cluster, and manage the cluster through deploying applications and services, scaling systems, performing updates, and much more. On a Linux system, there are several ways to install the kubectl
binary and to keep it up to date.
In this tutorial, we will cover several ways to install kubectl
on all major Linux distributions. This will include installing the kubectl binary via direct download, or from various system package managers.
Keep in mind that your kubectl version should correspond with the rest of your cluster. In other words, it is recommended to keep everything up to date, rather than updating kubectl on its own, or letting it fall out of date from the rest of the cluster. If the kubectl version does not match up with your cluster, it is likely to cause issues.
In this tutorial you will learn:
- How to download and install the kubectl binary manually
- How to install kubectl via apt package manager
- How to install kubectl via dnf package manager
- How to install kubectl with Snap universal package manager

Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | Kubernetes, kubectl |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install kubectl Linux Binary
You have the option to download the
kubectl
Linux binary directly from the official Kubernetes site, and then keep it up to date manually. Another option is to use your system’s package manager to download kubectl
and keep it updated that way. The latter option is probably easier for most users, but the former gives you more control. Use whichever method below that you find most appropriate.
Method 1: Manual installation of kubectl
First, let’s see how to download the kubectl
binary and install it manually:
- Use the following
curl
command to download the latest stable release of the kubectl Linux binary:$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- Next, it is a good idea (but optional) to verify the checksum of the download. If your download resulted in a corrupt file for any reason, it could result in downtime or painstaking troubleshooting later on. Use these commands to download the checksum file and verify the binary:
$ curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" $ echo "$(cat kubectl.sha256) kubectl" | sha256sum --check kubectl: OK
- Now we can move on to installing kubectl:
$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- You can check to see that you are now running the updated version of kubectl by executing:
$ kubectl version --client
Method 2: Using apt package manager
This method will work for Ubuntu Linux, Debian Linux, and any other distribution that uses the
apt
package manager.
- Start off by installing the following prerequisite packages:
$ sudo apt update $ sudo apt install -y ca-certificates curl apt-transport-https
- Next, grab the Google Cloud public signing key with
curl
:$ sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
- Then, execute the following command to add the Kubernetes repository to your package manager:
$ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
- Now we can use the ordinary
apt install
command to download kubectl:$ sudo apt update $ sudo apt install kubectl
Method 3: Using dnf package manager
This method will work for Fedora Linux, Red Hat Enterprise Linux, and any other Linux distribution that uses the dnf
package manager.
- First, use the following command to add the Kubernetes repository to your system:
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch enabled=1 gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF
- Lastly, install the kubectl binary with your
dnf
package manager:$ sudo dnf install kubectl
Method 4: Using snap package manager
Ubuntu comes with Snap installed by default, and many users also choose to install Snap on other distributions. It is a universal package manager, so the following command will work on any Linux distribution that already has Snap installed:
$ sudo snap install kubectl --classic
Closing Thoughts
In this tutorial, we saw how to install the kubectl binary on a Linux system. The kubectl tool allows administrators to control their cluster and keep an eye on all pertinent info. We saw several ways of how we can easily install the binary file and keep it up to date. Be sure to keep it updated alongside the same version number as your Kubernetes cluster to ensure that the command can continue communicating with the cluster as intended.