How to Install Google Cloud CLI (Command-Line Interface) on Mac, Windows, and Linux
How to Install Google Cloud CLI on Mac, Windows, and Linux
Introduction
The Google Cloud CLI (Command-Line Interface) is an essential tool for developers and IT professionals working with Google Cloud Platform (GCP). It allows you to interact with GCP services directly from the terminal, making it easier to manage resources, deploy applications, and automate workflows. In this guide, we’ll cover the step-by-step process to install Google Cloud CLI on Mac, Windows, and Linux systems.
Whether you’re just starting with Google Cloud or are an experienced user looking to streamline your workflow, this guide will provide everything you need to get up and running.
Prerequisites
Before proceeding, ensure you have the following:
- A Google Cloud account. If you don’t have one, sign up for free.
- Administrative rights on your machine to install software.
- An active internet connection to download the required packages.
Step 1: Install Google Cloud CLI on Mac
- Method 1: Using Homebrew (Recommended)
If you’re on a Mac, the easiest way to install Google Cloud CLI is via Homebrew:
Open Terminal.
Run the following command to install Google Cloud SDK:
brew install –cask google-cloud-sdk
After the installation completes, initialize the SDK:
gcloud init
Follow the on-screen instructions to authenticate and set up your project.
- Method 2: Manual Installation
If you prefer to install it manually:
Download the installer from Google Cloud CLI Downloads.
Unzip the file:
tar -xvf google-cloud-sdk-*.tar.gz
Navigate to the unzipped folder:
cd google-cloud-sdk
Run the installer:
./install.sh
Follow the prompts to complete the installation.
Initialize the SDK:
gcloud init
Step 2: Install Google Cloud CLI on Windows
- Method 1: Using PowerShell (Recommended)
Open PowerShell as an administrator.
Run the following command to download and install the Google Cloud SDK:
Invoke-WebRequest -Uri https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe -OutFile GoogleCloudSDKInstaller.exe; Start-Process .\GoogleCloudSDKInstaller.exe
Follow the on-screen instructions in the installer.
Once installed, initialize the SDK:
gcloud init
- Method 2: Manual Installation
Download the installer from Google Cloud CLI Downloads.
Run the installer and follow the setup wizard.
Ensure the option to add gcloud to your PATH is checked.
Once installation is complete, open Command Prompt and run:
gcloud init
Step 3: Install Google Cloud CLI on Linux
- Method 1: Using APT (Debian/Ubuntu)
Update your package list:
sudo apt update
Install the required dependencies:
sudo apt install apt-transport-https ca-certificates gnupg
Add Google Cloud’s official GPG key:
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –
Add the Cloud SDK distribution URI:
echo “deb https://packages.cloud.google.com/apt cloud-sdk main” | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
Install Google Cloud SDK:
sudo apt update && sudo apt install google-cloud-sdk
Initialize the SDK:
gcloud init
- Method 2: Using YUM (RHEL/CentOS/Fedora)
Add the Cloud SDK repo:
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM
Install Google Cloud SDK:
sudo yum install google-cloud-sdk
Initialize the SDK:
gcloud init
Step 4: Authenticating and Configuring Google Cloud CLI
Once you have installed Google Cloud CLI, you need to authenticate your account and set up your project:
gcloud auth login
A browser window will open asking you to log in to your Google account. Once done, return to the terminal.
Set your default project:
gcloud config set project YOUR_PROJECT_ID
Step 5: Verify Installation
To ensure everything is installed correctly, run:
gcloud version
This will display the installed components and versions. If everything is in order, you’re all set to use Google Cloud CLI.
Common Commands to Get You Started
List all Google Cloud projects:
gcloud projects list
Create a new VM instance:
gcloud compute instances create INSTANCE_NAME –zone=us-central1-a
Deploy a Google App Engine application:
gcloud app deploy
Conclusion
Installing Google Cloud CLI on your system is a straightforward process, and once set up, it opens up a world of possibilities for managing your Google Cloud resources efficiently. With this guide, you now have the steps needed to install and configure the CLI on Mac, Windows, and Linux. Make sure to explore more of the Google Cloud CLI documentation to make the most out of this powerful tool.
Thank you for visiting our website! If you’re looking to improve your skills with Linux systems and would like to read our article on “How to Install and Configure OpenVPN on Ubuntu Server,” you can access it through the link below. Happy learning! 🙂
How to Install and Configure OpenVPN on Ubuntu Server