Setting Up Google Cloud SDK For GCP On Arch/Manjaro Linux
Tags: gcp, gcloud, gsutil, archlinux
Published: 2018-09-19 16:39:53

---
title: Setting Up Google Cloud SDK For GCP On Arch/Manjaro Linux
published: true
description: We can build cloud servers by using GCP [Google Cloud Platform]. This article shows how to install gcloud/gsutil to manage GCP.
tags: gcp, gcloud, gsutil, Arch Linux
cover_image: https://thepracticaldev.s3.amazonaws.com/i/7r6b85t44088me0cou3x.jpg
---

## Intro

[Manjaro Linux](https://manjaro.org/), based on [Arch Linux](https://www.archlinux.org/), is my favorite Linux distribution for development.
This is because of its rolling release and [AUR \[Arch User Repository\]](https://aur.archlinux.org/) -- a pretty large repository and useful packages.

[GCP \[Google Cloud Platform\]](https://cloud.google.com/) is also wonderful for cloud computing.
It gives both service power and cost validity to startups.

## Summary

In order to manage GCP from the command line, Google provides [Google Cloud SDK](https://cloud.google.com/sdk/).

This article shows how to set up GCP management environment on Arch/Manjaro Linux.

\* *note* : The official Linux packages are available on [Debian/Ubuntu](https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu) and [Redhat/CentOS (except Fedora)](https://cloud.google.com/sdk/docs/quickstart-redhat-centos).

<center>✿ ✿ ✿</center>

## Step 1: Account Activation

First of all, we must have a Google Cloud account.
[Free trial is available.](https://console.cloud.google.com/freetrial/)
Its free service is listed [here](https://cloud.google.com/pricing/free/).

\* *note* : we can/needn't create a project at this time.

## Step 2: google-cloud-sdk Installation

Next, we need to install "google-cloud-sdk" package.
AUR package is available.

\* *note* : Or we can choose manual installation by following [the official quickstart tutorial of Google Cloud SDK for Linux](https://cloud.google.com/sdk/docs/quickstart-linux). The tool version might be fixed this way.

Open terminal and type like this:

```shell
$ git clone https://aur.archlinux.org/google-cloud-sdk.git

$ cd google-cloud-sdk/
$ # pkgbuild is necessary
$ makepkg -si
$ # authenticate for installation if required

$ # remove resource after installation
$ cd ../
$ rm -rf google-cloud-sdk/
```

## Step 3: Initialization

Here, just type `gcloud init` and a couple of the following steps on terminal will bring us to completion 😉

Like this:

```shell
$ gcloud init

Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
The Reachability Check passed.
Network diagnostic (1/1 checks) passed.

You must log in to continue. Would you like to log in (Y/n)?  

...

# authorization via web browser will be required

...

You are logged in as: [{% your@account %}].

Pick cloud project to use: 
 [1] {% your-project if exists %}
 [2] Create a new project
$ Please enter numeric choice or text value (must exactly match list 
item):  1 # or you can create a new project by selecting "2"

Your current project has been set to: [{% your-existing-project %}].

$ Do you want to configure a default Compute Region and Zone? (Y/n)?  n

Created a default .boto configuration file at [/home/{% your-name %}/.boto]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use {% your@account %} by default
* Commands will reference project `{% your-project %}` by default
Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.

Some things to try next:

* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic -h` to learn about advanced features of the SDK like arg files and output formatting
```

<center>✿ ✿ ✿</center>

## Conclusion

Now `gloud` / `gsutil` commands are in our hands 😆

#### Basic Commands & References

Let's use `gcloud` basic commands:

```
$ # show some info
$ gcloud auth list
$ gcloud config list
$ gcloud info

$ # show help
$ gcloud help
```

`gcloud` reference is [here](https://cloud.google.com/sdk/gcloud/reference/).

And then, let's go ahead to `gsutil`:

```
$ # show some info
$ gsutil ls

$ # show help
$ gsutil help
```

`gsutil` reference is [here](https://cloud.google.com/storage/docs/gsutil/).

#### Usage Example #1

One of the most simple command examples is perhaps managing vm instances.

```
$ gcloud compute instances start {% instanc-name %}
$ gcloud compute instances stop {% instanc-name %}
```

Their details are here: [start](https://cloud.google.com/sdk/gcloud/reference/compute/instances/start/) and [stop](https://cloud.google.com/sdk/gcloud/reference/compute/instances/stop/).

#### Usage Example #2

Now we can manage project objects.
For example, when creating custom vm image, these commands are useful: 

```
$ # to add resource
$ gsutil cp -a public-read {% local-image.tar.gz %} gs://{% bucket-name %}/{% server-image %}.tar.gz
$ # to remove resource
$ gsutil rm gs://{% bucket-name %}/{% server-image %}.tar.gz

$ # to create vm image
$ gcloud compute --project {% project-name %} images create {% vm-name %} --source-uri gs://{% bucket-name %}/{% server-image %}.tar.gz
$ # to delete vm image
$ gcloud compute --project {% project-name %} images delete {% vm-name %}
```

Their details are here: [gsutil cp](https://cloud.google.com/storage/docs/gsutil/commands/cp), [gsutil rm](https://cloud.google.com/storage/docs/gsutil/commands/rm) and [gcloud compute](https://cloud.google.com/sdk/gcloud/reference/compute/).

There are also a [gsutil quickstart](https://cloud.google.com/storage/docs/quickstart-gsutil/).

<center>✿ ✿ ✿</center>

Thank you very much for your reading.
Happy coding 😃