Skip to content

Server login

Learning outcomes


You might already be able to do some or all of these learning outcomes. If so, you can go through the corresponding exercises quickly. The general aim of this chapter is to work comfortably on a remote server by using the command line.

After having completed this chapter you will be able to:

  • Use the command line to:
    • Make a directory
    • Change file permissions to ‘executable’
    • Run a bash script
    • Pipe data from and to a file or other executable
  • Program a loop in bash

Choose your platform

In this part we will show you how to access the cloud server, or setup your computer to do the exercises with conda or with Docker.

If you are doing the course with a teacher, you will have to login to the remote server. Therefore choose:

  • Cloud notebook

If you are doing this course independently (i.e. without a teacher) choose either:

  • conda
  • Docker

If you are participating in this course with a teacher, you have received a link and a password. Copy-paste the link (including the port, e.g.: http://12.345.789.10:10002) in your browser. This should result in the following page:

Type your password, and proceed to the notebook home page. This page contains all the files in your working directory (if there are any). Most of the exercises will be executed through the command line. We use the terminal for this. Find it at New > Terminal:

For a.o. efficiency and reproducibility it makes sense to execute your commands from a script. You can generate and edit scripts with New > Text File:

Once you have opened a script you can change the code highlighting. This is convenient for writing the code. The text editor will automatically change the highlighting based on the file extension (e.g. .py extension will result in python syntax highlighting). You can change or set the syntax highlighting by clicking the button on the bottom of the page. We will be using mainly shell scripting in this course, so here’s an example for adjusting it to shell syntax highlighting:



First login

Docker can be used to run an entire isolated environment in a container. This means that we can run the software with all its dependencies required for this course locally in your computer. Independent of your operating system.

In the video below there’s a tutorial on how to set up a docker container for this course. Note that you will need administrator rights, and that if you are using Windows, you need the latest version of Windows 10.

The command to run the environment required for this course looks like this (in a terminal):

Modify the script

Modify the path after -v to the working directory on your computer before running it.

docker run \
--rm \
-v /path/to/workingdir/:/home/jovyan \
-p 8888:8888 \
geertvangeest/ngs-longreads-jupyter:latest \

If this command has run successfully, you will find a link and token in the console, e.g.:

Copy this URL into your browser, and you will be able to use the jupyter notebook.

The option -v mounts a local directory in your computer to the directory /home/jovyan in the docker container (‘jovyan’ is the default user for jupyter containers). In that way, you have files available both in the container and on your computer. Use this directory on your computer to e.g. visualise data with IGV. Change the first path to a path on your computer that you want to use as a working directory.

Don’t mount directly in the home dir

Don’t directly mount your local directory to the home directory (/root). This will lead to unexpected behaviour.

The part geertvangeest/ngs-longreads-jupyter:latest is the image we are going to load into the container. The image contains all the information about software and dependencies needed for this course. When you run this command for the first time it will download the image. Once it’s on your computer, it will start immediately.

If you have a conda installation on your local computer, you can install the required software using conda.

You can build the environment from ngs-longreads.yml

Generate the conda environment like this:

conda env create --name ngs-longreads -f ngs-longreads.yml

The yaml file probably only works for Linux systems

If you want to use the conda environment on a different OS, use:

conda create -n ngs-longreads python=3.6

conda activate ngs-longreads

conda install -y -c bioconda \
samtools \
minimap2 \
fastqc \
pbmm2 \

conda install -y -c bioconda nanoplot

If the installation of NanoPlot fails, try to install it with pip:

pip install NanoPlot

This will create the conda environment ngs-longreads

Activate it like so:

conda activate ngs-longreads

After successful installation and activating the environment all the software required to do the exercises should be available.

A UNIX command line interface (CLI) refresher

Most bioinformatics software are UNIX based and are executed through the CLI. When working with NGS data, it is therefore convenient to improve your knowledge on UNIX. For this course, we need basic understanding of UNIX CLI, so here are some exercises to refresh your memory.

Make a new directory

Login to the server and use the command line to make a directory called workdir.

If working with Docker

If your are working with docker you are a root user. This means that your “home” directory is the root directory, i.e. /root, and not /home/username. If you have mounted your local directory to /root/workdir, this directory should already exist.

mkdir workdir

Make a directory scripts within ~/workdir and make it your current directory.

cd workdir
mkdir scripts
cd scripts

File permissions

Generate an empty script in your newly made directory ~/workdir/scripts like this:


Add a command to this script that writes “SIB courses are great!” (or something you can better relate to.. 😉) to stdout, and try to run it.


The script should look like this:

#!/usr/bin/env bash

echo "SIB courses are great!"

Usually, you can run it like this:


But there’s an error:

bash: ./ Permission denied

Why is there an error?


Use ls -lh to check the permissions.

ls -lh


-rw-r--r--  1 user  group    51B Nov 11 16:21

There’s no x in the permissions string. You should change at least the permissions of the user.

Make the script executable for yourself, and run it.


Change permissions:

chmod u+x

ls -lh now gives:

-rwxr--r--  1 user  group    51B Nov 11 16:21

So it should be executable:


More on chmod and file permissions here.

Redirection: > and |

In the root directory (go there like this: cd /) there are a range of system directories and files. Write the names of all directories and files to a file called system_dirs.txt in your working directory (~/workdir; use ls and >).

ls / > ~/workdir/system_dirs.txt

The command wc -l counts the number of lines, and can read from stdin. Make a one-liner with a pipe | symbol to find out how many system directories and files there are.

ls / | wc -l


Store system_dirs.txt as variable (like this: VAR=variable), and use wc -l on that variable to count the number of lines in the file.

cd ~/workdir
wc -l $FILE

shell scripts

Make a shell script that automatically counts the number of system directories and files.


Make a script called e.g.

#!/usr/bin/env bash
cd /
ls | wc -l


20 minutes

If you want to run the same command on a range of arguments, it’s not very convenient to type the command for each individual argument. For example, you could write dog, fox, bird to stdout in a script like this:

#!/usr/bin/env bash

echo dog
echo fox
echo bird

However, if you want to change the command (add an option for example), you would have to change it for all the three command calls. Amongst others for that reason, you want to write the command only once. You can do this with a for-loop, like this:

#!/usr/bin/env bash

ANIMALS="dog fox bird"

for animal in $ANIMALS
  echo $animal

Which results in:


Write a shell script that removes all the letters “e” from a list of words.


Removing the letter “e” from a string can be done with tr like this:

echo $word | tr -d "e"

Which would result in:


Your script should e.g. look like this (I’ve added some awesome functionality):

#!/usr/bin/env bash

WORDLIST="here is a list of words resulting in a sentence"

for word in $WORDLIST
  echo "'$word' with e's removed looks like:"
  echo $word | tr -d "e"

resulting in:

'here' with e's removed looks like:
'is' with e's removed looks like:
'a' with e's removed looks like:
'list' with e's removed looks like:
'of' with e's removed looks like:
'words' with e's removed looks like:
'resulting' with e's removed looks like:
'in' with e's removed looks like:
'a' with e's removed looks like:
'sentence' with e's removed looks like: