After all that awesome time I had during SAGE DAYS 25, I still feel there is something I haven't done. There were many people asking about how to use SAGE. Although they have seen how to use notebook, they are not sure how to run a sage notebook server. This blog post is intended to enable a layman start with using sage.
This blog post will be in three parts
- How to get sage
- How to use sage on the terminal
- How to start and use a notebook server
How to get sage:
Visit this link and get the corresponding binary. Follow the instructions for extracting the binary. I now assume your sage is in a directory called SAGE_DIR.
Ex: my SAGE_DIR is /home/nishanth/sage-4.5/
From now on, where ever I use SAGE_DIR please replace it with your sage directory.
How to use sage on the terminal:
Using sage interactively:
First go to your terminal and do "cd SAGE_DIR"
then do "./sage"
it takes a while and gives you sage prompt. Which means you will see "sage:" on your terminal waiting for input.
This is the sage shell and you can type your sage code interactively line by line over here.
Running a file that contains sage code:
Simply pass the path to that file as an argument. In simple words, also type the path to file after you do "./sage"
Ex: ./sage /home/myscripts/mycode.sage
If the filename ends in ".sage" the file is run as a sage code. If the filename ends in ".py" the code is run as a pure python code.
How to start and use a notebook server:
Use notebook at home:
type "notebook()" on the sage prompt and it starts the server. Go to your web browser and open the url "http://localhost:8000" and go ahead.
Use notebook as a server for academic purposes:
A single instance of server can handle only around 30 - 40 simultaneous connections. So you might want to run multiple instances and just notebook() will not suffice.
Use notebook(interface="", port=<your desired port>, directory=path_where_to_store, timeout=120)
Ex: notebook(interface="", port=8080, directory="/home/nishanth/sagenb_8080", timeout=60)
This server can be accessed by "http://<server ip>:8080"
To run next instance, use a different port and different directory.

