kubectl command not found - Ubuntu

Page content

How to Install kubectl Command on Ubuntu

If you are working with Kubernetes clusters, you will often need to use the kubectl command line tool to interact with the cluster. However, if you find that the kubectl command is not available on your Ubuntu system, you will need to install it.

Installation Steps

To install kubectl on Ubuntu, follow these steps:

  1. First, update the package list to ensure you have the latest version information:

    sudo apt update
    
  2. Install the kubectl package using curl:

    sudo apt install -y curl
    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    
  3. Make the kubectl binary executable:

    chmod +x ./kubectl
    
  4. Move the kubectl binary to a directory in your PATH, such as /usr/local/bin:

    sudo mv ./kubectl /usr/local/bin/kubectl
    
  5. Verify that kubectl is installed by checking the version:

    kubectl version --client
    

Compatibility Issue

If you encounter any compatibility issues with the installation steps above, make sure you are using the correct version of kubectl for your Ubuntu system. You can check the available versions on the Kubernetes release page.

Conclusion

By following these steps, you should now have kubectl successfully installed on your Ubuntu system. You can now use this command line tool to manage your Kubernetes clusters efficiently.