How to Install Kubectl in Ubuntu?

We are going to use the debian package managers to install Kubectl in Ubuntu.

sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2

Example Output

Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease                                                                                                    
Hit:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease                                                                                                                              
Hit:4 https://packages.microsoft.com/repos/ms-teams stable InRelease                                                                                                                              
Hit:5 http://ppa.launchpad.net/ubuntuhandbook1/gimp/ubuntu focal InRelease                                                                              
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]                                                        
Hit:7 http://archive.ubuntu.com/ubuntu focal InRelease                                                               
Get:8 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                                               
Get:9 https://apt.releases.hashicorp.com focal InRelease [4,419 B]                              
Get:10 https://apt.releases.hashicorp.com focal/main amd64 Packages [20.8 kB]
Fetched 248 kB in 3s (93.0 kB/s)     
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (2.0.4).
The following package was automatically installed and is no longer required:
  libllvm10
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  gnupg2
0 upgraded, 1 newly installed, 0 to remove and 33 not upgraded.
Need to get 4,584 B of archives.
After this operation, 51.2 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 gnupg2 all 2.2.19-3ubuntu2.1 [4,584 B]
Fetched 4,584 B in 1s (8,013 B/s)  
Selecting previously unselected package gnupg2.
(Reading database ... 217875 files and directories currently installed.)
Preparing to unpack .../gnupg2_2.2.19-3ubuntu2.1_all.deb ...
Unpacking gnupg2 (2.2.19-3ubuntu2.1) ...
Setting up gnupg2 (2.2.19-3ubuntu2.1) ...
Processing triggers for man-db (2.9.1-1) ...

Example 2

> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
OK