This page describes the variety of ways you can configure Cloud Shell to customize your experience.
Configuration files in your Cloud Shell home directory
Cloud Shell provisions 5 GB of free
persistent disk storage mounted as
$HOME directory. All files you store in your home directory, including
installed software, scripts and user configuration files like
.vimrc, persist between sessions.
.bashrc persists across sessions, it's a great way to customize
your Cloud Shell behavior. Similarly, you can install packages into your home
directory to have your installations persist.
Pre-configured environment variables
When Cloud Shell is started, the active project in Console is propagated to
gcloud configuration inside Cloud Shell for immediate use.
GOOGLE_CLOUD_PROJECT, the environmental variable used by
Application Default Credentials library support to define project ID, is also
set to point to the active project in Console.
CLOUD_SHELL environment variable is set to
true. This variable can be
checked from applications to determine if an application is running in Cloud Shell.
gcloud command-line tool preferences
When using Cloud Shell, your gcloud command-line preferences
are stored in a temporary
tmp folder, set for your current tab only, and do
not persist across sessions.
To have your gcloud command-line configurations persist, you can choose to set them using one of the following methods:
To keep your gcloud command-line tool configuration customizable per tab but customize the default configuration itself, you can add
gcloudconfiguration commands (such as
gcloud config set compute/region us-central1to set a default region) to the end of your
This ensures that every new tab inherits your Cloud Console project and your customized default configuration but also allows you to further customize each tab's configuration.
To always use the same gcloud command-line tool configuration, add
export CLOUDSDK_CONFIG=$HOME/.gcloudto the end of your .bashrc file, and then run
gcloud config configurations create CONFIG_NAMEto create the configuration you'd like to use.
To set the project you'd like to work on, run:
gcloud config set project [PROJECT_NAME]
Your command prompt updates to reflect your currently active project,
respecting this format:
To select your preferred region, run:
gcloud config set compute/region us-east1
The commands above are examples of gcloud command-line tool configurations you can set; for a full list and greater detail about setting properties, refer to the Cloud SDK properties guide.
Environment customization allows you to install additional packages into your Cloud Shell environment when it starts.
Environment customization script
Cloud Shell automatically runs the script,
when your instance boots up. Unlike
.bashrc, this script runs
once when Cloud Shell boots (rather than once for each shell login).
This script runs as root and you can install any packages that you want to exist in each Cloud Shell session using Debian package management commands.
For example, if you'd like to have erlang installed on Cloud Shell,
.customize_environment file will look like this:
#!/bin/sh apt-get update apt-get -y install erlang
Execution logs of your
.customize_environment script can be found
script runs as a background process and on successful execution, will touch
/google/devshell/customize_environment_done. Because package installation
runs in parallel with your logging in, the installed packages may become
available a few moments after you reach the login prompt.
Container image customization
Container image customization allows you to create a Docker image that functions as a custom Cloud Shell environment with your specified additional packages and custom configurations. Your Docker image must be based on the base Cloud Shell image and hosted in Container Registry.
For details on how to create a custom container image, see the Customizing container image guide.
Unlike environment customization, container image customization doesn't affect your default Cloud Shell experience. You can use and share your custom image with Open in Cloud Shell links.
Cloud Shell uses
tmux by default, which allows it to improve
persistence across browser tab sessions. For example, if you refresh the
Cloud Console in a tab or connect to your Cloud Shell from a
different machine, the session state will not be lost.
Cloud Shell supports the default
tmux key bindings. For
example, if you press Ctrl+b and then %,
tmux splits the current
session window into left and right panes, which can be useful for debugging.
tmux in Cloud Shell, click the Terminal Settings button
(wrench icon), select Tmux Settings and de-select the
Enable Tmux Integration option.
Cloud Shell collects anonymized usage statistics on commands that are run inside the Cloud Shell terminal. Statistics are collected only on commands that come pre-installed in the Cloud Shell. Additionally, these metrics cannot be tied back to your account.
Metrics aren't collected on any personally identifiable information, such as arguments passed to these commands.
To change metrics collection preferences at any time, select Terminal Usage Statistics in the Settings menu . Any change in your preferences on the Settings menu takes effect on the next session. You'll have to close your tab and open another one once you've made your change to enable/disable metrics collection.
Note: This is separate from gcloud usage statistics, which is enabled by default in Cloud Shell.
To disable gcloud command-line tool metrics collection, run the following command in your Cloud Shell session:
gcloud config set disable_usage_reporting true