The terminal and remote login

Instructor note

Total: 30min (Teaching:20Min | Discussion:0min | Breaks:0min | Exercises:0Min | Type-along-pause:10 min )

Prerequisites

  • An active user account on one of the HPC systems (clusters)

Get an user account and access to a project

 https://www.sigma2.no/how-apply-user-account

Objectives

  • Questions

    • What is UNIX ?

    • What is a termial/Command line/UNIX shell, why do we need it

    • What does it mean by login in to a remote system ?

    • What is ssh

  • keypoints

    • The UNIX terminal

    • The ssh program

    • Connect to a remote HPC system.

Instructor note

First excersice

  • Introduce the shared document

  • Short pause for people to login

  • Open the shared document and start the discussion, while the learners type in answers

CLI (Command Line Interface)

Before we dive in to what CLI is, we shall remind our selves of how do we ask a computer to do something of us, nicely of course.

What are the methods you know that we can use to interact with a computer

Use the interactive document to write down the answers

What is UNIX

UNIX is an Operating System(OS). Operating systems is a software that makes a computer usable, by managing the hardware, other software and automated tasks that are needed for the computer to work. Windows, MacOS, Android,Chrome OS and Ubuntu are some examples of operating systems. There are different flavors of UNIX and except Windows all the other examples above are flavors of UNIX. Versions of Windows 10 and newer has support to executing UNIX commands as well. In short if you are not on a old version of Windows, you already have access to a program that can execute the UNIX command that is used to connect to the remote machine as described in this lessons.

What is a CLI

CLI (Command Line Interface) also referred to as the Terminal/Command line/UNIX shell/ UNIX terminal refers not to a single program, but an user interface that interprets text inputs to machine understandable instructions. Shell is a program(s) that uses this method of interface. There are different variants of the Shells as well and a common one is Bash and we shall focus on that during this lesson. In addition to being an CLI, bash is also a scripting language.

We will use the term terminal to refer to the CLI and use bash flavor of the shell

Why do we need to use the terminal

  • Efficient way to achieve complex tasks. Some examples;

    • Rename 1000 files by prepending the string “latest” to their names

    • Group a collection of RAW, PNG and JPG files in sub-folders by their type

    • Extract the first 10 lines of 100 files and place it in anew file

    • Count how many lines starts with a “>” in a files with 1 million lines. Then extract those matching lines to a new file.

  • Work on a remote computers

  • Pipelines. Combine multiple commands to achieve a repetitive task

Instructor note

Try to show how to locate the terminal using different methods and on different operating systems if possible. Please upload screen-shots of different methods to this lesson.

Find my terminal

Most of the operating system flavors one of the following two methods will bring up the default terminal. Do not worry if if the default terminal do not support all bash commands, as we will use the default terminal only to establish connection to the remote HPC system where we shall execute the other commands described in this lesson.

  • ALT + CTRL + T (press down ALT key, CTRL key and then press the T)

OR

  • In the program search box type terminal

Windows Windows search

MacOs Mac search

If the above failed to locate the terminal then do a internet search “how to open terminal on MY-OS-NAME” where MY-OS-NAME is the operating system you are on.

If you are on an older Windows version (Windows 7) you could download the program called Git SCM to Windows and that will be your terminal to connect to the HPC system.

A Terminal

Instructor note

Use interactive document to vote for I found my terminal or I can not find my terminal

What is SSH (Secure Shell)

SSH is a protocol (established set of rules) used to make it possible for two computers to securely communicate over the network (internet is a network well, a huge one). In this lesson we will be referring to the ssh command when we say SSH, which is actually a SSH client. You could think of ssh as a program that could establish a connection to a remote machine that supports SSH connection (a machine that runs the SSH server).

Logging in to a remote HPC system

The first step in using a cluster is to establish a connection from our laptop to the cluster, via the Internet and/or your organization’s network. We use a program ssh for this. Make sure you have a SSH client installed on your laptop terminal.

Test if ssh is installed before proceeding

Check ssh version

[user@laptop ~]$ ssh -V

OpenSSH_x.x xx, OpenSSL xxx xxx

ssh installed and OK to continue

Danger

[user@laptop ~]$ ssh -V

Command ‘ssh’ not found

Not OK! stop and inform instructor

Connect to cluster

Instructor note

Use interactive document to vote for

  • I have ssh

  • I do not have ssh

  • I am lost, what you mean by ssh

Go ahead and log in to the cluster:

Remember to replace MY_USER with the username you received after registering for an account. You may be asked for your password.

Warning

The characters you type after the password prompt are not displayed on the screen. Normal output will resume once you type the passward and press Enter.

[user@laptop ~]$ ssh MY_USER_NAME@saga.sigma2.no

You are logging in using using ssh. This establishes a temporary encrypted connection between your laptop and compute cluster. The word before the @ symbol, e.g. MY_USER_NAME here, is the user account name that you have permission to use on the cluster.

Where are we?

Very often, many users are tempted to think of a high-performance computing installation as one giant, magical machine. Sometimes, people will assume that the computer they’ve logged onto is the entire computing cluster. So what’s really happening? What computer have we logged on to? The name of the current computer we are logged onto can be checked with the hostname command. (You may also notice that the current hostname is also part of our prompt!)

[MY_USER_NAME@login-1.SAGA ~]$ hostname

login-1.saga.sigma2.no