introduction to linux - acrc.bris.ac.uk to linux.pdf · introduction to linux university of bristol...
TRANSCRIPT
Introduction to Linux
University of Bristol - Advance ComputingResearch Centre
1 / 37
Operating SystemsProgram running all the timeInterfaces between other programs andhardwareProvides abstractions (common interfaces,e.g. filesystems)
You may know
WindowsMacOSiOSAndroid
2 / 37
UNIXAn operating system originating at BellLabs. circa 1969 in the USA
3 / 37
User InterfacesCommand LineGUI - Graphical User Interface
4 / 37
Kernels and ShellsThe kernel is the core of the operatingsystemThe shell is the interface between the useraand the operating system
5 / 37
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
Linux PhilosophyKit of partsOne small thing does one thing wellSmall utilities can be joined together toperfom more complicated tasks
7 / 37
Bits and Pieces
8 / 37
At First...
$ ls | wc -l
9 / 37
But Later...
tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn |
10 / 37
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
Filesystem Hierarchy
12 / 37
DirectoriesPathnames and /Finding where you are (pwd)Changing to a different Directory (cd)The Directories . and ..Home directories (~)
13 / 37
Tasks 1find out where you arewhat is pathname one level above (gothere)go back to your home directory (prove it)
14 / 37
New Files and DirectoriesListing files and directories (ls)Making Directories (mkdir)
15 / 37
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
File ManipulationCopying Files (cp)Moving Files (mv)Removing Files and directories (rm)
17 / 37
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
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
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
FilenamesWildcards
? Any character* More Than One Character
Filename Conventions (e.g. .c)
21 / 37
Tasks 5list all the two letter commands in /usr/binlist all the commands with "to" in theirname
22 / 37
Getting Helpmanman -kGoogle (other search engines are available)
23 / 37
Tasks 6Read the man page for headPick a random command from in /usr/binand read it's manpage
24 / 37
Maniputaing Filessortuniq
25 / 37
RedirectionRedirecting the Output
> (overwrites)>> (appends)
Redirecting the Input<
26 / 37
Tasks 7sort the file authors into alphabetical orderfind the list of unique authorsfind how many time each appears in theoriginal list
27 / 37
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
29 / 37
Tasks 8without using intermediate files...
sort the authors filefind the count of unique authorsput that list in to numerical order
30 / 37
Text Editorsnot Wordvim is mentioned a lot but don't use just yet
we recommend nano
^O to save^X to exit
31 / 37
Task 9add some more authors to the authors filererun the previous analysisput the analysis command pipleine in to afile called author_count
32 / 37
Any Questions?
33 / 37
34 / 37
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
[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
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