Stefano Marseglia



The following is a collection of useful commands and Tips to start using magma on the UU server Gemini.
  1. Basics
    • First you will need some kind of terminal with ssh installed.
      If you are a Linux or MacOS user, then you are good to go.
      If you are using Windows, then you can use ssh in Powershell, or use the Windows Subsystem for Linux (WSL) and install a Linux distro.
      (I use and recommend the latter: you can then manipulate all your files using Linux programmes and the integration works very well. Tip: to figure out in which folder you are in WSL use explorer.exe .).
    • Login into the server:
      ssh [your-student-number/Solis-ID]@gemini.science.uu.nl
    • You will be asked the password every time. In order to skip this step when you are logging in from you laptop, you can generate an RSA Key and upload the public key. Note that if you already have an RSA key, you can reuse the same public key.
      This is nicely explained in this online tutorial.
    • Basic Linux commands at this link.
      The most important ones are cd, ls, mv, cp, rm, mkdir, rmdir, cat.
      In order to access the complete documentation of a command use man [command]. For example man ls.
      Important: rm permanently deletes a file!
    • If you want to re-run a command that you have already used, you don't have to re-type it:
      use the up/down arrows to move in the history of what have you typed in before, modify the command and run it.
      This trick is particularly useful if you made a typo while writing a command.
    • The standard bash settings on gemini are not the best one. For example, it does not tell you in which folder you are.
      To do so you can add settings to the .bashrc file which you can find in you home folder. If the files is not there you can create a new one.
      At the following link you can find what my .bashrc looks like.
    • It is useful to create aliases to avoid typing always the same commands:
      see this link.
  2. Move/Modify files
    • To upload file.txt to gemini:
      scp file.txt [your-student-number/Solis-ID]@gemini.science.uu.nl:~/[destination folder]
      The destination folder has to already exist.
    • To download a file from gemini:
      scp [your-student-number/Solis-ID]@gemini.science.uu.nl:~/[path to file] ./
      The command ./ means the current folder.
    • One can also edit text files directly on the server, for example with vim, emacs or nano.
      If the connection is not stable or has a lag, this approach can become quite frustrating.
      There are editors such as VisualStudioCode with packages for continuous synchronization of local files to a server.
      Or, you can experiment with the following script I wrote.
      (I write directly my code on the server using vim.)
    • If you want to synchronize a large number of files between different machines, I suggest to use rsync.
    • In order to download a file from the web you can use the command wget followed by the link to the file.
    • Advanced: If you are developing a package, you can use git and GitHub.
      This is typically where programmers publish their code.
  3. Running computations
    • Once you are on gemini, to open Magma type the following commands:
      module load magma
      magma
    • The commands to load packages in Magma are Attach(), AttachSpec() and load.
      You can also immediately load a package while opening magma with magma your_file
      . While doing this you can also assign variables: Say that in your_file you have an unassigned variable var, then you with magma your_file var:=10
      , you will assign it to 10. Note that 10 will be read as a string (and not an integer!). So you have to evaluate it inside the program.
      See the Magma documentation for more info.
      (It might complain that it is not a 'safe' website....go figure...)
    • If you want to run a long computation, then use the command screen. It allows you to detach from the current screen and let it run the background.
    • Advanced: The server gemini has several cores. If you want to use simultaneously more than one core, you can use parallel.
      Don't forget that gemini is used by several department! Don't run long parallel computations!
      gemini has a queue system, which I haven't used yet.