How Colab Notebooks work
What is a Colab Notebook?
A Colab Notebook is a sort of “special” Google document hosted in the cloud that can be accessed with any browser. Usage is possible only to users logged in on Google.
A notebook is a sequence of text cells and of code cells. To run a code cell just click on the triangle on the left. You can execute (and re-execute) cells in any order. While a cell is running, no other cell can be run. You can run cells as you want: other people will not see the output of your executions.
Notebooks are meant to be read from the beginning, in sequence. You can go back and forth and experiment as you want, however.
Where is code executed?
Code cells are executed by a Linux virtual machine hosted on the Google cloud and associated with the notebook. Such a machine is volatile, i.e., once the notebook is closed all the state of the machine, including files, is lost (maybe not immediately).
Different users on the same notebook have different machines, thus executions of different users are fully isolated from each other. You can modify the notebook (by adding/modifying text/code cells) as you want. The modified copy will be visible only to yourself. If you want to save the modified copy, the notebook will force you to save it with a different name.
The Linux virtual machine associated with a notebook has some limitations. The most crucial one is that it has strong limitations in interacting with the Internet. Essentially, you cannot run any server (more precisely, you could run servers but those servers would not be reachable from other machines).
What kind of code can a Notebook execute?
Notebooks are mostly used with code cells that contain Python code. Some cells contain Linux commands. Such commands begin with ‘!’. Some notebooks are composed of only Linux commands without any code.
Colab is similar to Jupyter. Jupyter is a tool for interactive execution of Python programs. It requires the installation and configuration of Python and of the Jupyter environment. Colab can instead be used with a browser, without locally installing anything.