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 a user account and access to a project
https://www.sigma2.no/how-apply-user-account
https://www.uio.no/english/services/it/research/platforms/edu-research/help/fox/account-login.md
Objectives
Questions
What is UNIX ?
What is a terminal/Command line/UNIX shell, why do we need it
What do we mean by logging 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 log in
Open the shared document and start the discussion, while the learners type in answers
CLI (Command Line Interface)
Before we dive into what CLI is, let’s remind ourselves of how we ask a computer to do something for us.
What are the methods you know for interacting with a computer?
Use the interactive document to write down the answers
What is UNIX
UNIX is an Operating System(OS). An operating system 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 have support to executing UNIX commands as well, while older versions do not.
What is a CLI
The CLI (Command Line Interface) also referred to as the Terminal/Command line/UNIX shell or UNIX terminal, is a user interface that interprets text inputs to machine-understandable instructions. Shell is a program that use this method of interface. There are different variants of the Shells as well and a common one is Bash, which we will focus on during this lesson. In addition to being a CLI, bash is also a scripting language.
We will use the term terminal to refer to the CLI and use the 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 a new file
Count how many lines start with a “>” in a file with 1 million lines. Then extract those matching lines to a new file.
Work on remote computers
Pipelines: combine multiple commands to achieve a repetitive task
Find my terminal
Most of the operating system flavors will bring up the default terminal using one of the two methods described below.
Do not worry if your default terminal does not support all bash
commands we will be using in this lesson, as we will use the default terminal only to establish connection to the
remote HPC system. The rest of the commands will be executed on the remote HPC system itself.
Instructor note
Try to show how to locate the terminal using different methods and on different operating systems if possible.
ALT + CTRL + T
(press down ALT key, CTRL key and then press the T)
OR
In the program search box type
terminal
Windows
This is how it looks like in Windows when you search for the terminal.
MacOs
And this is how it looks like in Mac when you search for your terminal.
What if you did not find a terminal?
If the above methods failed to locate the terminal, then do an 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.
Components of a terminal
Instructor note
Use the 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 a network (internet is a (huge) network).
Logging in to a remote HPC system
The first step in using a cluster is to establish a temporary encrypted connection from our laptop to the cluster,
via the Internet and/or your organization’s network using ssh
.
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
Instructor note
Use the 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 will 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 password and press Enter
.
[user@laptop ~]$ ssh MY_USER_NAME@saga.sigma2.no
[user@laptop ~]$ ssh MY_USER_NAME@fram.sigma2.no
[user@laptop ~]$ ssh MY_USER_NAME@betzy.sigma2.no
[user@laptop ~]$ ssh MY_USER_NAME@fox.educloud.no
One-Time_Code:
Password:
Where are we?
It is not uncommon that users think that a high-performance computing installation is one
giant, magical machine. Sometimes, people will assume that the computer they’ve logged on to 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
(MY_USER_NAME@login-1.fram.sigma2.no): hostname
login-1.fram.sigma2.no
[MY_USER_NAME@login-1.BETZY ~]$ hostname
login-1.betzy.sigma2.no
[MY_USER_NAME@login-4 ~]$ hostname
login-4.fox.ad.fp.educloud.no