introduction to linux - acrc.bris.ac.uk to linux.pdf · introduction to linux university of bristol...

37
Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37

Upload: others

Post on 08-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Introduction to Linux

University of Bristol - Advance ComputingResearch Centre

1 / 37

Page 2: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Operating SystemsProgram running all the timeInterfaces between other programs andhardwareProvides abstractions (common interfaces,e.g. filesystems)

You may know

WindowsMacOSiOSAndroid

2 / 37

Page 3: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

UNIXAn operating system originating at BellLabs. circa 1969 in the USA

3 / 37

Page 4: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

User InterfacesCommand LineGUI - Graphical User Interface

4 / 37

Page 5: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Kernels and ShellsThe kernel is the core of the operatingsystemThe shell is the interface between the useraand the operating system

5 / 37

Page 6: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

LinuxA version of UNIXWritten by Linux Torvalds when he was anundergrad in FinlandFree (libre, gratis)One OS from Desktop -> SupercomputerTechnically just the kernelDistributions bundle kernel, GNU tools andextra softwareBlueCrystal Phase 3 runs CentOS 6

6 / 37

Page 7: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Linux PhilosophyKit of partsOne small thing does one thing wellSmall utilities can be joined together toperfom more complicated tasks

7 / 37

Page 8: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Bits and Pieces

8 / 37

Page 9: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

At First...

$ ls | wc -l

9 / 37

Page 10: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

But Later...

tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn |

10 / 37

Page 11: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Logging OnWe'll be working on the HPC (Blue Crystal)

Start PuttyLog in to bluecrystal phase 3:

train##@bluecrystalp3.bris.ac.uk

Where ## is your account number, ietrain01

First commands, get the example data:

cp -r ../intro_to_linux .cd intro_to_linux

And off we go...11 / 37

Page 12: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Filesystem Hierarchy

12 / 37

Page 13: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

DirectoriesPathnames and /Finding where you are (pwd)Changing to a different Directory (cd)The Directories . and ..Home directories (~)

13 / 37

Page 14: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 1find out where you arewhat is pathname one level above (gothere)go back to your home directory (prove it)

14 / 37

Page 15: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

New Files and DirectoriesListing files and directories (ls)Making Directories (mkdir)

15 / 37

Page 16: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 2What is in your home directory?What is on one level above?Make a new directory in your homedirectory ( give it a one word name)

16 / 37

Page 17: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

File ManipulationCopying Files (cp)Moving Files (mv)Removing Files and directories (rm)

17 / 37

Page 18: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 3copy example.txt to another filenamerename your new file to something elsemove you new file in to the directory youcreated earliermake another copy of example.txtdelete your second copy

18 / 37

Page 19: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Examining File ContentsDisplaying the contents of a file on thescreen (cat, less)The first lines in a file (head)The last lines in a file (tail)Searching the contents of a file (grep)Counting with grep (-c)UNIX is case sensitivegrep -i

19 / 37

Page 20: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 4What is in example.txtWhat are the first 10 lines of example.txtWhat are the first 15 lines of example.txtWhat are the last 2 lines of example.txtRead through the whole of example.txt apage at a timeFind all the lines that mention "GNU"Count the number of lines that have theword "Linux" (in any capitalisation)

20 / 37

Page 21: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

FilenamesWildcards

? Any character* More Than One Character

Filename Conventions (e.g. .c)

21 / 37

Page 22: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 5list all the two letter commands in /usr/binlist all the commands with "to" in theirname

22 / 37

Page 23: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Getting Helpmanman -kGoogle (other search engines are available)

23 / 37

Page 24: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 6Read the man page for headPick a random command from in /usr/binand read it's manpage

24 / 37

Page 25: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Maniputaing Filessortuniq

25 / 37

Page 26: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

RedirectionRedirecting the Output

> (overwrites)>> (appends)

Redirecting the Input<

26 / 37

Page 27: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 7sort the file authors into alphabetical orderfind the list of unique authorsfind how many time each appears in theoriginal list

27 / 37

Page 28: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Pipes and PipelinesTake the standard output of one commandand feed it in to the standard input of thenextUses the pipe (vertical bar) symbol |No intermediate files!

Efficient

28 / 37

Page 29: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

29 / 37

Page 30: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Tasks 8without using intermediate files...

sort the authors filefind the count of unique authorsput that list in to numerical order

30 / 37

Page 31: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Text Editorsnot Wordvim is mentioned a lot but don't use just yet

we recommend nano

^O to save^X to exit

31 / 37

Page 32: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Task 9add some more authors to the authors filererun the previous analysisput the analysis command pipleine in to afile called author_count

32 / 37

Page 33: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Any Questions?

33 / 37

Page 34: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

34 / 37

Page 35: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

Resources - Where to practisemacOS users can use the terminalWindows10 has Windows Subsystem forLinuxDepartmental resourcesEligible users can apply for an account onthe ACRC clustersCloud vendors provide trial subscriptions

35 / 37

Page 36: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

[email protected] Website -https://www.bristol.ac.uk/acrc/http://swcarpentry.github.io/shell-novice/http://www.ee.surrey.ac.uk/Teaching/Unix/

36 / 37

Page 37: Introduction to Linux - acrc.bris.ac.uk to Linux.pdf · Introduction to Linux University of Bristol - Advance Computing Research Centre 1 / 37. O pe rati ng Sy ste ms Program running

CreditsLicence

This work is licensed under a CreativeCommons Attribution-ShareAlike 4.0International License.

Based on previous versions by

Rob Thomas - ACRCUniversity of Surrey

Image Credits

Redirects and Pipes (c) SoftwareCarpentry CC-BY-4.0 37 / 37