
Repairing the Cloud Shell
There are some cases in which your Cloud Shell can become damaged. Because Cloud Shell is running on a Linux virtual machine, activities such as modifying system files may result in unexpected behavior. This kind of issue can usually be repaired by simply destroying and provisioning a new instance of the underlying virtual machine. This can be done at any time by clicking the Restart button under the Cloud Shell settings. Doing so will destroy all sessions and restore all system files to the default state. Files in the $HOME directory will persist across the restart process.
There are also some configuration files within the $HOME directory that the Cloud Shell depends on to function correctly. Since these configuration files exist in the $HOME directory, issues created here will persist across restarts. In many cases, this can be solved by simply deleting the $HOME directory and restarting the Cloud Shell.
In some cases, deleting the $HOME directory may be insufficient or undesired. For example, if a change in the .bashrc file causes an error, the Cloud Shell will immediately terminate any new sessions. If this occurs, the Cloud Shell can be started in safe mode by appending ?cloudshellsafemode=true to the URL, for example, https://console.cloud.google.com?cloudshellsafemode=true. This will cause the Cloud Shell to log in as root and skip loading configuration files in the $HOME directory, allowing users to either fix the issues or delete the $HOME directory entirely.