> For the complete documentation index, see [llms.txt](https://devops.books.c-k.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devops.books.c-k.dev/kubernetes/installation/install-kubectl.md).

# Install kubectl

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.

### Install kubectl on Linux <a href="#install-kubectl-on-linux" id="install-kubectl-on-linux"></a>

#### Install kubectl binary with curl on Linux <a href="#install-kubectl-binary-with-curl-on-linux" id="install-kubectl-binary-with-curl-on-linux"></a>

1. Download the latest release with the command:

   ```
   curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
   ```

   To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version.

   For example, to download version v1.14.0 on Linux, type:

   ```
   curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/linux/amd64/kubectl
   ```
2. Make the kubectl binary executable.

   ```
   chmod +x ./kubectl
   ```
3. Move the binary in to your PATH.

   ```
   sudo mv ./kubectl /usr/local/bin/kubectl
   ```
4. Test to ensure the version you installed is up-to-date:

   ```
   kubectl version
   ```

#### Install using native package management <a href="#install-using-native-package-management" id="install-using-native-package-management"></a>

* [Ubuntu, Debian or HypriotOS](https://kubernetes.io/docs/tasks/tools/install-kubectl/#kubectl-install-0)
* [CentOS, RHEL or Fedora](https://kubernetes.io/docs/tasks/tools/install-kubectl/#kubectl-install-1)

```

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
```

#### Install with snap <a href="#install-with-snap" id="install-with-snap"></a>

If you are on Ubuntu or another Linux distribution that support [snap](https://snapcraft.io/docs/core/install) package manager, kubectl is available as a [snap](https://snapcraft.io/) application.

1. Switch to the snap user and run the installation command:

   ```
   sudo snap install kubectl --classic
   ```
2. Test to ensure the version you installed is up-to-date:

   ```
   kubectl version
   ```
