introduction to linux for bluebear - intranet.birmingham.ac.uk · overview logging in to bluebear...

45
Introduction to Linux for BlueBEAR May 2018 www.bear.bham.ac.uk

Upload: others

Post on 31-Aug-2019

39 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Introduction to Linuxfor BlueBEAR

May 2018 www.bear.bham.ac.uk

Page 2: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Overview

Logging in to BlueBEAR

Introduction to basic Linux commands

Understanding of the BlueBEAR workflow

Basic file management

Write and run a simple program

Preparation for BEAR Necessities

Page 3: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Introduction to BlueBEAR

Page 4: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

What is BEAR?

http://intranet.birmingham.ac.uk/bear

Birmingham Environment for Academic

Research

BlueBEAR refers to the Linux High

Performance Computing (HPC) environment

BEAR is a collection of services: HPC,

storage, fast networking, ...

BEAR services are FREE at the point of use

Page 5: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

BlueBEAR

Users need to register to use the service

Users are attached to (multiple) projects

Projects are created by staff

Projects are used to account for time on the

cluster

Registrations are via:

https://intranet.birmingham.ac.uk/it/teams/infr

astructure/research/bear/bluebear/bluebear-

registration.aspx

Page 6: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

BlueBEAR Workflow

Page 7: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Accessing and using BlueBEAR

Page 8: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Accessing BlueBEAR

You must register for access to BlueBEAR

You will need an SSH client (e.g. PuTTy); Mac users

- Terminal

You can connect to the cluster from the University

network or via Remote Access Service (apply via

ServiceDesk)

Use your normal University (ADF) username and

password

Interface is command line

X service for graphical applications, e.g. Exceed,

XQuartz (Mac)

Page 9: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Exceed

Download from My Software –

mysoftware.bham.ac.uk

This is used for graphical applications

Page 10: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Setting up PuTTY

Host name: 172.31.11.62

Saved Sessions: bluebear training

Instructions here: https://intranet.birmingham.ac.uk/it/teams/infrastructure/research/bear/b

luebear/accessing-bluebear-using-putty-and-exceed.aspx

Page 11: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Setting up PuTTY to use with Exceed Graphical interface – makes it pretty! Needed for

some applications, e.g. gedit text editor

Open Exceed before PuTTY – from Start menu

In PuTTY load the Saved Session, e.g. bluebear

training

Click on + next to SSH, then click on X11

Tick the box to Enable X11 forwarding

Click Save

Click Open to start the session

Accept security warning

Log in

Page 12: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Setting up PuTTY to use with Exceed

Page 13: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Logging in from a Mac

Install XQuartz – www.xquartz.org

Run to allow configuration setup. XQuartz will

be available in Applications/Utilities

Open xterm or Terminal

Type ssh <username>@bluebear.bham.ac.uk

At the command prompt type gedit

Page 14: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Workshop 1

Time: 10 minutes

Open Exceed

Open and set up PuTTY

Log in to BlueBEAR training - 172.31.11.62

Page 15: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

The Command Line

Type in commands

Commands, Files and programs are CaSe-

SeNsItIvE

Spaces are key – get them in the right place

You type commands into a program called

the “shell”

Text can be copied from other sources, e.g.

Notepad

Page 16: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Help? How do I use this command?

Each command

should have a

manual page for it.

– To view it type man command,

e.g. to view the

manual for the man command type:

man man

Press q to quit,

use the arrow keys to scroll

Page 17: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Directories and files

Unlike Windows there are no “drives” (i.e. no ‘C:\’, ‘D:\’, ‘U:\’ etc.)

Everything exists under a directory, ‘/’, called the root directory.

Useful directories to know:

– ‘/rds/homes/x/username’ – each user usually has a directory here

with their own files in it, known as their ‘home directory’.

– ‘/tmp’ – temporary files. Any user can create files in this directory.

Often deleted when the computer reboots.

On BlueBEAR there is also ‘/scratch’ on each compute node

which is for the same purpose but much larger.

Page 18: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Structure

A path is where the system looks to find

programs (Not where you walk!)

echo $PATH

These are already set up on BlueBEAR

Command not found – the program isn’t in

your path

Page 19: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Storage

Available on all nodes:

– Your home directory (20GB quota)

For settings, ssh keys etc.

– RDS (/rds/projects/...)

– Should be used for all data, job scripts,

output etc.

Page 20: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Creating a file - nano From the command prompt type nano

Runs in the terminal window

Enter text

Commands are at the bottom of the screen –

ctrl+[letter], e.g. ctrl+w to find (“Where Is”),

ctrl+x to exit

ctrl+o to save (“WriteOut”), enter a file name,

press enter

Alphanumeric filenames

Page 21: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

nano

Page 22: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Creating a file - gedit From the command prompt run gedit - a graphical

interface to type your file content – this uses Exceed

Enter some sample text

Click Save (the 3 lines icon gives more options, e.g.

Save As…, Find…Print)

Best not to use unusual characters in filenames -

alphanumeric

It is easy to specify where your file is stored in the

directory structure on the server

Can open existing files

Page 23: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

gedit

Page 24: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Basic file commands:

ls – list files(don’t delete

ones starting with . !)

cd – change

directory

pwd – print current (working) directory

Page 25: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Basic file commands:

Basic file commands:

less filename – view the contents of

your (text) files (press q to quit),

space to page down, up/down arrows

cat filename – view the contents of a

file, better for smaller files

Page 26: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Basic file commands:

head filename – watch the start of file as it

grows

tail -f filename – watch the end of file as

it grows

Page 27: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Tips and tricks Press the up arrow and you will see your previous commands,

so can use them again

Type history at the command prompt and you will see the

history of what you have typed and re-run commands

The ‘tab’ key is magic, pressing it:

– once: complete the current command or filename if there is

one match

– twice: list all the matching options if there is more than one

match

CTRL+c or Q will return you to the command ($) prompt

cd ~ returns to home directory

CTRL+z stops processes

clear – clears screen and returns to $ prompt

Page 28: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

File management:

Basic directory management commands:

mkdir newdirectory – create directory

rmdir directory – remove directory (only

works if directory is empty). Note there is no

warning/confirmation message!

Page 29: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Organising files:

Basic file management commands:

– touch file –

create an empty file

– rm file – remove a file

(there is no recycle bin!)

– cp file newfile – copy a file

(creates a duplicate)

– mv file newfile – move a file

(renames the file)

Page 30: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Editing files Can edit from Windows and use share

If file has been created in Windows, you can

use dos2unix to make it Linux-friendly

– Windows files use different line endings

dos2unix ~/filename

Lots of editors under Linux

– nano is a basic, easy to use one

– Others – joe, vim, emacs

Page 31: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Editing files View and edit a file:

– Check the contents of the file - cat [filename] or

less [filename]

– Edit the file in nano: try CTRL+k, CTRL+u,

CTRL+w to see what they do

Page 32: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Workshop 2Time: 30 minutes

View the example file bearcloud (in testing

directory)

Create a directory called username_test

Create a file in nano or gedit (or both if you have

time!), add some content, save and close

Edit the file

List your files

View the contents of the file(s) you created

Page 33: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

File permissions:

Files (and directories) can have different

permission sets for groups and users

Files Directory

r – read the file r – list contents of directory

w – write to the file w – create new files/folders

x – execute (run) x – traverse (e.g. cd to directory)

Page 34: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Example file permissions: Try doing

ls –ld ~/

This shows permissions on home directory

First character indicates file (-), directory (d) or link (l),

next 3 characters is user

next 3 group

final 3 is all other users

Page 35: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Some useful tools

grep string filename

– Look for number of occurrences in the file

e.g. bear!

– grep BEAR README

– What does

grep –c BEAR README do?

Page 36: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Scripts

Allow series of commands to be repeated

Can pass arguments in, use variables etc.

Need to be “executable” to run from

command line

First line shows the “interpreter” (or shell) to

use, e.g.

#!/bin/bash

Page 37: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Scripts Use the text editor to create a new script file to:

– Create a directory (mkdir)

– Change to a directory (cd)

– List the directory contents with all details (ls)

– Create a new empty file (touch)

– List the directory contents with all details (ls)

Remember to set the shell in the first line

#!/bin/bash

Make it executable (chmod) – to get the right permissions to run

it – e.g. chmod u+x scriptname

Run the script

./SCRIPTNAME

Page 38: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Workshop 3

Page 39: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Workshop 3Time: 20 minutes

View the example program simple_script

Write a basic program to say “hello my name

is X”

Run the program

Look at file permissions for the program

Page 40: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Example script

#!/bin/bash

mkdir ~/tempdir

cd ~/tempdir

ls -al

touch somefile

ls -al

Page 41: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Help is available

If you’re having any

problems visit the IT

Service Desk in a web

browser:https://universityofbirmingham.service-now.com/

Page 42: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Other BEAR services and information

Page 43: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Other BEAR Services Research Data Store (RDS): FREE storage for research

projects (up to 3TB per project)

Research Data Archive (RDA): long term storage of data

associated with published research

BEAR DataShare: File synchronisation and sharing service

Research Data Network (RDN): dedicated network to connect

research facilities that generate very high volumes of data

BEARView: Large scale visualisation of complex data

BEAR Cloud: Local high-performance cloud computing

integrated with campus services

BEAR Software: Free advice/help from BEAR Research

Software Engineers

... and more at https://intranet.birmingham.ac.uk/bear

Page 44: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Special Interest Groups

SIGs for (currently):

– Bioinformatics

– Computational Fluid Dynamics (CFD)

– Finite Element Method (FEM)

– MATLAB

– Stata

https://intranet.birmingham.ac.uk/collaboration/hpc-research/index.aspx

Page 45: Introduction to Linux for BlueBEAR - intranet.birmingham.ac.uk · Overview Logging in to BlueBEAR Introduction to basic Linux commands Understanding of the BlueBEAR workflow Basic

Questions?