Using SageMath on CS Department Linux Machines

Instructions based on Piazza posts from students from previous years.

Using SageMath

Sage is installed on the CS department machines, but is not included in your path. To add it to your path, you can execute the command export PATH=/usr/local/sage:$PATH. You will have to run this command everytime you use Sage unless you add this command to your .bashrc file. Once Sage has been added to your path, you can run sage -n jupyter to run the notebook. If it does not automatically open a browser, you can open one yourself and visit http://localhost:8888/tree.

Using SageMath remotely

When working remotely, there are two options: X11 forwarding and port forwarding. For both options, ensure that the notebooks are saved in an accessible directory on the remote machine.

X11 Forwarding

X11 forwarding works by running everything locally on the department machine and sending the window drawing to your machine. As such, it can be somewhat slow. To start an ssh connection with X11 forwarding enabled, add -X as an option to ssh:
ssh -X <username>@<machine>.cs.colostate.edu
Depending on your operating system, you may need to install packages to make this work - MacOS, for example, requires Xming or an equivalent.

Port Forwarding

Port forwarding works by connecting the ports on the two machines. Here we make port 8888 on your machine redirect to port 8888 on the university machine. To port forward, log into the CS machine using
ssh -L 8888:localhost:8888 <username>@<machine>.cs.colostate.edu
Then you will want to run
sage -n jupyter --no-browser
where you will see
terminal
you can then visit the URL displayed when you run Sage on the CS machine and access the notebook:
browser

If you are using PuTTy, enter your host as normal
PuTTy
Then navigate to Connections/SSH/Tunnels
PuTTy
Then enter in

  • localhost:8888 for Source port
  • localhost:8888 for Destination
Click Add. This is just setting up the same steps as described above, forwarding the department machines localhost:8888 to your localhost:8888
PuTTy
Then you can connect and use the terminal as normal.