How to install GNOME Graphical interface on Ubuntu loaded on Google Cloud VM instance.

Login to Google Clound and launch your Ubuntu Terminal via VM Instance. Once at terminal screen copy / paste below command:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install gnome-shell
$ sudo apt-get install ubuntu-gnome-desktop
$ sudo apt-get install autocutsel
$ sudo apt-get install gnome-core
$ sudo apt-get install gnome-panel
$ sudo apt-get install gnome-themes-standard

  1. When presented with a prompt to continue or not, typeyand select ENTER, as shown in the following screenshot:
  2. Once done with the preceding steps, type the following commands to set up the vncserver and allow connections to the local shell:

$ sudo apt-get install tightvncserver
$ touch ~/.Xresources

  1. Next, launch the server by typing the following command:

$ tightvncserver

This will prompt you to enter a password, which will later be used to log in to the Ubuntu Desktop virtual machine. This password is limited to eight characters and needs to be set and verified, as shown in the following screenshot:

A startup script is automatically generated by the shell, as shown in the following screenshot. This startup script can be accessed and edited by copying and pasting its PATH in the following manner:

In our case, the command to view and edit the script is:

:~$ vim /home/amrith2kmeanmachine/.vnc/xstartup

This PATH may be different in each case. Ensure you set the right PATH. The vim command opens up the script in the text editor on a Mac.

NOTE: The local shell generated a startup script as well as a log file. The startup script needs to be opened and edited in a text editor.

After typing thevimcommand, the screen with the startup script should look something like this screenshot

Type i to enter INSERT mode. Next, delete all the text in the startup script. It should then look like the following screenshot:

Copy paste the following code into the startup script:

autocutsel -fork
xrdb $HOME/.Xresources
xsetroot -solid grey
export XDG_CURRENT_DESKTOP=”GNOME-Flashback:Unity”
export XDG_MENU_PREFIX=”gnome-flashback-“
gnome-session –session=gnome-flashback-metacity –disable-acceleration-check –debug &

The script should appear in the editor, as seen in the following screenshot:

  1. Press Esc to exit out of INSERT mode and type :wq to write and quit the file.
  2. Once the startup script has been configured, type the following command in the Google shell to kill the server and save the changes:

$ vncserver -kill :1

This command should produce a process ID that looks like the one in the following screenshot:

Start the server again by typing the following command:

$ vncserver -geometry 1024×640

You can use SSH command from local machine:

$ gcloud compute ssh \
–ssh-flag “-L 5901:localhost:5901”

Once you see the name of your instance followed by ":~$", it means that a connection has successfully been established between the local host/laptop and the Google Cloud instance. After successfully SSHing into the instance, we require software called VNC Viewerto view and interact with the Ubuntu Desktop that has now been successfully set up on the Google Cloud Compute engine. The following few steps will discuss how this is achieved.

  1. VNC Viewer may be downloaded using the following link:

Once installed, open VNC Viewer and connect to external ip address::5901

This will prompt you to enter your password for the virtual machine. Enter the password that you set earlier

You will finally be taken into the desktop of your Ubuntu virtual machine on Google Cloud Compute

How it works…

You have now successfully set up VNC Viewer for interactions with the Ubuntu virtual machine/desktop. Anytime the Google Cloud instance is not in use, it is recommended to suspend or shut down the instance so that additional costs are not being incurred. The cloud approach is optimal for developers who may not have access to physical resources with high memory and storage.