# Getting Started with Cloud Shell and gcloud

## Overview

Cloud Shell provides you with command-line access to computing resources hosted on Google Cloud. Cloud Shell is a Debian-based virtual machine with a persistent 5-GB home directory, which makes it easy for you to manage your Google Cloud projects and resources. The `gcloud` command-line tool and other utilities you need are pre-installed in Cloud Shell, which allows you to get up and running quickly.

## Setup

### Activating Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

Hitting the cloud shell icon on the top right activates it as shown below.

![](/files/3kR1KgDp9Wlcky9PUU5y)

### Listing Active Account

```
gcloud auth list
```

![](/files/jHShTAlOy2TpbTZxIE8A)

### Listing Project ID

```
gcloud config list project
```

![](/files/cZuQAtwEb3SHNCUpQBzA)

## Configuring Environment

### Get Project Information

```
gcloud compute project-info describe --project <your_project_ID>
```

![](/files/xbvu4uS9KOJDiyJv8xH2)

### Check Gcloud config

```
gcloud config list
```

![](/files/t2ZYWw8rIGL5N29AEIM5)

### Export Environment Variables

#### Project ID

```
export PROJECT_ID=<your_project_ID>
```

#### Region/Zone

```
export ZONE=<your_zone>
export ZONE=asia-southeast1-a
```

![](/files/hW79AN9ApbUla2J38DuD)

### Creating a VM with Gcloud

```
gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone $ZONE
```

* `gcloud compute` = Enables user to manage compute resources
* `instances create` = Create a new instance in the virtual environment
* `gcelab2` = name of the VM
* `--machine-type` = user selected machine type
* `--zone` = region and zone user likes the VM to be spawned in

## Installing Components

`gcloud interactive` has auto prompting for commands and flags and displays inline help snippets in the lower section of the pane as the command is typed.

You can use dropdown menus to auto-complete static information, such as command and sub-command names, flag names, and enumerated flag values.

### Install and enable

```
sudo apt-get install google-cloud-sdk
gcloud beta interactive
```

![](/files/H8Zpc6wvygTaLNx35vmJ)

### Autocomplete Mode

We were basically able to use the Gcloud interactive shell together with the autocomplete feature and explanation of commands and grab the brief description of the VM that we had just created as shown below.

![](/files/SdguUDHwKbfIpn0bXPEg)

![](/files/99oMNqAXIIAA8LRhTKPm)

## SSH into VM (via Gcloud)

### Initiate an ssh connection

```
gcloud compute ssh gcelab2 --zone $ZONE
```

![](/files/fj3Y5iQ6jeJjCM6Il7Xs)

![](/files/3ymuALD1E7d4VHypAaOS)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://repo.4pfsec.com/google-cloud-computing/cloud-computing-fundamentals/getting-started-with-cloud-shell-and-gcloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
