Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the...

64
Introduction to Linux/Unix for HPCC users Xiaoge Wang, ICER [email protected] Aug. 16, 2017

Transcript of Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the...

Page 1: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Introduction to Linux/Unix for HPCC users

XiaogeWang,[email protected]

Aug.16,2017

Page 2: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Goal •  Prerequisitefor“IntroducEontoHPCC”•  MostcommonlyusedbasicLinuxcommandsamongHPCCusers

•  UnderstandsimpleLinuxshellscript

Page 3: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

How does this class work

Taskdrivenlearningmethod–  DescripEonofatask–  DemonstrateasoluEonofataskbyinstructor–  handsonexercises.

UsethesEckynotesprovidedtohelpmehelpyou.

–  Nos%cky=Iamworking–  Green=Iamdoneandreadytomoveon(yea!)–  Red=IamstuckandneedmoreEmeand/orsomehelp

Page 4: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 5: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 6: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Introduction

•  Bigmap–  Linux/Unix–  Shell

•  Overview– Commands–  SimpleShellscript– GetreadyforHPC.

Page 7: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Big picture

Shell Shell

Page 8: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents
Page 9: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Overview

•  Commands•  SimpleShellscript•  GetreadyforHPC

Page 10: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 11: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 12: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:

•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 13: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 1: Connect to HPCC •  Task:connectfromyourPCtoHPCCdevelopnodesusingyour

account.•  SoluEon:threesteps

–  Stepone:•  get/openyourclient

–  Terminalsession»  Windowsusers

MobaXterm»  Macusers

Terminal,»  Linuxusers

Terminal–  Remotedesktop:rdp.hpcc.msu.edu

–  Steptwo:•  $ssh–[email protected],(rsync.hpcc.msu.edu)

–  Stepthree:•  $sshdev-nodename

•  Note:–  Firstcommand“ssh”,itisobenreferas“login”,“connect”–  Readmessageonloginpage.–  Howtoreportproblem:client,gateway,node,account,errormessage,

Eme,locaEon.

Page 14: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Connect to HPCC

•  Remotedesktop–  InstallRemoteDesktopclient– CreateaconnecEon

•  PCname:rdp.hpcc.msu.edu•  Username:•  Password:

–  Startremotedesktop•  Clickon“TerminalEmulator”

Page 15: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 1: connect to HPCC

•  Task:– Use/installyourclienttoconnecttooneofdevnode,makesureyoureadtheloginmessagesmessage

– Type“gmod”

Page 16: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC

•  Runyourprogram– Parttwo:

•  Scripts•  Otherusefulstuff

•  Summary

Page 17: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2: Set up working environment •  Gettoknowmyworkingplace

– Hardware–  Sobware–  Storage

•  Setupmyworkingenvironment– Obtainsobwarepackages– Preparedata–  Setenvironmentvariable

Page 18: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.1: Get info

1.  Systeminfo2.  Sobwareinfo3.  Storagespace

Page 19: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.1.1:System info

•  Systemandkernal$uname–a

•  Numberofcores$nproc–all

•  SizeofRam$free–h

•  CPUinfo$lscpu

Page 20: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.1.1: get system info

•  Getthesysteminfoofthedev-node:–  Systemandkernel–  Numberofcores–  SizeofRam(memory)–  CPUinfo

Page 21: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.1.2:Software info •  Viewthesystemavailablesobware

$modulelist#currentlyloaded$moduleavail#allavail$modulespider$moduleloadpowertools

•  Wherearetheyinstalled?$ls/opt/soCware

•  WhichversionamIusing?Numberofcores$whichpython$python--version

•  Isthereanyexamplesorhelpsofthesobwarepackages?$getexample$getexample<example_name>

Page 22: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.1.2:find a tool

(1)Checkifsobware“perbools”isavailable.Ifitisavailable,runfollowing“pprof”commandof“perbools”:

$pprof--helpDoyouknowwhereisitinstalled?(2)Findthelatestversionof“iw”andmoduleloaditfordevelopmentofsobware.Getexampleofiw.(3)FindtheversionofaCcompiler“cc”

Page 23: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.1.3:Storage info •  Whereismy“finder”or“windowsexplorer”?

–  Rootofsystem:/–  Homedirectory:~/,$HOME–  Researchdirectory(space):

/mnt/research/<name_group>–  Scratchspaceforuserandresearchgroup:

$SCRATCH,/mnt/scratch/wangx147–  /tmp(noprivatespace)

•  Size,usageandcontentofthespace?–  $quota,–  $df–h/mnt/research/helpdesk,–  $lfsquota-uwangx147/mnt/scratch–  $pwd,$cd<directory>,$ls,$ls–al,$ls–R

Page 24: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.1.3:get storage info

•  Findthesizeandcontentsofyour–  Homedirectory–  Scratchspace–  /tmp

•  Findtheusageofdirectory/opt/sobware

Page 25: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Navigation

•  Understandstructureofstorage–  Spaces(DiskparEEon)

•  home:/mnt/home/NetID•  Scratch:/mnt/scratch/NetID•  Research:/mnt/research/GroupName

–  Directories(folder)•  “tree”

–  Files•  Filename:absolute/relaEve

–  Shortcuts•  ~,$HOME,$SCRTACH,..,./

Page 26: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents
Page 27: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents
Page 28: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.2: Set environment •  Obtainsobwarepackages

–  SobwareinstallaEon(notcovered)– Moduleload(done)

•  Preparedata–  Aboutafile– Makeadirectoryforfiles:$mkdir–  TransferfilesfromotherlocaEon–  Createfilelocallyusinganeditor

•  Setenvironmentvariables$exportPATH=/mnt/home/wangx147/bin:$PATH$exportOMP_NUM_THREADS=4$printenv

Page 29: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

All about a file

•  Aoributes:–  Accesspermission–  Owner–  Group–  Size– ModificaEonEme–  name

•  Example:$ls-lundelivered.err-rw-rw-r--1wangx147staff-np0Aug216:33undelivered.err

Page 30: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

File Access Permission •  Example:class0@dev-intel14-k20~]$ls-ltotal66-rw-r--r--1class0temporary48672Sep52012cheatsheet.pdf-rwxr-xr-x1class0temporary660Jan12015Colorfull.shdrwxr-xr-x2class0temporary3Oct1217:06Documents^^^^^^^^^^|||||||||||||||ownergroupsizeEmename||||numberoflinkstodirectorycontent|||permissionforallusers||permissionforthemembersofthegroup|permissionforownerTypeoffile.-=file,d=directory,l=link•  Changepermission

$chmod

Page 31: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Ownership

•  Changeonwership– $chownowner:groupfilename– $chown:groupfilename

Page 32: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

File Name

•  Fullname•  RelaEvename•  Changefilename:

$mvold_namenew_name

Page 33: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.2.1: Get or Create Files

•  Getfilesfromotherplaces–  $cpsource_filedest_file–  $wgetweb_address–  $curlweb_address– Moremethodswillbecoveredby“introtoHPCC”

•  Createfileslocally–  Createdirectory:mkdirdirname–  Redirectstandardoutputtofile:>,>>,>&,1>,2>–  Editor:nano

•  Note:

Page 34: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

|| visible in terminal || visible in file || existing Syntax || StdOut | StdErr || StdOut | StdErr || file ==== ======++==========+==========++==========+==========++=========== > || no | yes || yes | no || overwrite >> || no | yes || yes | no || append2> || yes | no || no | yes || overwrite 2>> || yes | no || no | yes || append &> || no | no || yes | yes || overwrite &>> || no | no || yes | yes || append

Page 35: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.2.1: Create a file

(1)  getacheatsheetfromInternetaddhop://steve-parker.org/sh/cheatsheet.pdf;

(2)  createadirectory“workshop”thatcontainsit;

(3)  Copyallfilesin/opt/sobware/zlib/1.2.8/includeto“workshop”

(4)  Createafile“List”whichrecordedallthefilesinthedirectory.

Hint:$cp/tmp/*.Couldcopyallfilein/tmptocurrentdirectory

Page 36: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.2.2: Look into Files

•  Openatextfilewithoutclickingmouse–  cat,head,head–n,tail,tail–n,more,less

•  SearchforaparEcularpaoernfromfiles–  grep,grep–r,grep–I,grep-v

•  OtherproperEesofafile– wc,

Page 37: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.2.2: Closer look

•  Task:Viewthecontentsofthedatafile“polls.csv”.FindouthowmanypollswererecordedfromMichigan.– GototheDATAdirectoryandviewthefile– Use“MI”tofindthedatarecordedfromMichigan.

Page 38: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 2.2.3Search for Files

•  Searchafilewith– Name–  Size– Time– Type

•  Example:findallversionofperl$find/opt/sobware/perl-nameperl-execls-l{}+$find/opt/sobware/perl-nameperl|grepbin

Page 39: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 2.2.3: Searching files

•  Task:findouthowmanyversionsofgcccompilerininstalledin/opt/sobware/GCC.

•  Hint:gcccompilerisstoredin…/bin/directory.Not…/lib/directory

Page 40: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment

– Parttwo:•  Scripts•  Otherusefulstuff

•  Summary

Page 41: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Task 3: run your program

•  Launchaprogramlocallyondevelopnodewithoutclickingmouse–  “cd”toworkinglocaEon–  SpecifyInputfiles–  SpecifyOutputfiles–  Environmentvariables

•  Launchbatchjobstorunoncomputenodes–  qsub(nocoveredhere)

•  Example$matlab–nodisplay–rtest_control_system

Page 42: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Monitor your program

•  $ps•  $top

Page 43: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

LETS TAKE A BREAK

Page 44: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

•  Otherusefulstuff•  Summary

Page 45: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

From Command to Script

Page 46: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Shell script

CombinemorecommandstogetherformoresophisEcate/complicatedtask.•  Variables

–  Environment:$HOME,$HOSTNAME,$PATH,$SCRATCH,$PWD,

–  Internallydefined–  DefinefromCommandlinearguments

•  expressions,expansion•  Controlflow(pipeline,branch,loops)•  ExecuEon(sourcevs.directrun,)

Page 47: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Control Flow: Pipeline •  Connectseveralcommandsinsequence,usestandardoutputofacommandasstandardinputofnextcommand

•  Example:countnumberoffilesunder/bin.–  SoluEon1:

ls/bin>bin_listwcbin_list

–  SoluEon2:ls/bin|wc

•  Learned:–  Ifastandardoutputcouldbeusedasstandard

inputofnextcommand,apipelinecouldbebuild–  Commonlyusedcommandsforpipelining:

•  grep,wc,sort,less,more,uniq,head,tail,…

Page 48: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Examples of pipeline

•  Filteringoutputshowq|grepBatchHold

•  SorEngtheoutputls–l|sort

•  CounEngls|wc-l

•  Beoerviewingps|more

Page 49: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 4: Pipeline

•  Task:Findouthowmanyjobsinjobqueue.Amongthem,howmanyarerunning.

1.  Counttotaljobsinjobqueue.Use“showq”togetlistofjobsinqueue.

2.  Countonlytherunningjobs.Usekeyword“Running”tofilterthejobs

Page 50: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Control Flow: branch

•  ControltheworkflowaccordingtocertaincondiEon

•  Formatif[condiEonistrue];then…dosomething...else…dosomethingelsehere...fi

Page 51: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Example :Branch

•  Task:Writeascript“scratch2home”thatwilltakeafilenameasinputandbackupthefilefromscratchspacetohomespace.Copyisneededonlyifthefileisneweronscratch.

•  CondiEon:fileisnewer•  Learn:

– ExpressionofcondiEon– Branch

Page 52: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 5: Branch

•  Task:followexampletowriteascript“home2scratch”thatwilltakeafilenameasinputandcopythefilefromhomespacetoscratchspaceifthefileisneweronhomespace.

Page 53: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Control Flow: Loop •  Runsomethingrepeatedlyover•  Format

–  Forloop:#!/bin/bashforiin$(ls);doechoitem:$idone

–  Whileloop#!/bin/bashCOUNTER=0while[$COUNTER-lt10];doechoThecounteris$COUNTERletCOUNTER=COUNTER+1done

–  UnElloop#!/bin/bashCOUNTER=20unEl[$COUNTER-lt10];doechoCOUNTER$COUNTERletCOUNTER-=1done

Page 54: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Example 6 :Loop

•  Task:SimilarasExample5exceptthatittakeadirectorynameasinputandbackupawholedirectory.Writeascript“scratch2home_dir”

•  Loopcount–  StaEc/dynamic

•  Learn:–  Loop

Page 55: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 6: Loop

•  Task:SimilarasExercise9exceptthatittakesadirectorynameasinputandcopyfilesinthedirectoryfromHomespacetoscratchspaceifanyfilesarenewer.Writeascript“home2scratch_dir”todoit.

•  Followexample10

Page 56: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Make Your Own Command

•  Makeshellscript“executable”– Chmod+x

•  Beawareof“environment”•  ExecuEon

–  “sourcename_script”vs.“./name_script”

Page 57: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Example 6 :Start Project •  Task:Getreadyforworkonaprojectonscratch.Createa

commandcalled“start_project”.Itwilldothefollowing–  Copyfilestoworkspace–  Updateaworklogfile–  Makesureitisready:datafiles–  Makethewholetaskasacommand

•  Commands–  $cp–rBuildModel$SCRATCH–  $date>>$SCRATCH/BuildModel/log–  $ls-l$SCRATCH/BuildModel/

•  Learn:–  Ifataskcouldbeimplementedbymorethansingleline

command/pipelineandisneededrepeatedly–  Environmentvariable$SCRATCH–  >>vs.>–  Filepermissionneedtosettoexecutable–  Additto$PATH

Page 58: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 6: Finish Project

•  Task:finishupaprojectworkingonscratch.– Runonscratchworkingdirectory– Backupdirectory– gobacktohomedirectory

•  followexample11tomakeacommand“finish_project”

Page 59: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts•  Otherusefulstuff

Page 60: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Agenda

•  IntroducEon•  Linux

– Partone:•  ConnecttoHPCC•  Setupyourworkingenvironment•  Runyourprogram

– Parttwo:•  Scripts

•  Summary

Page 61: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Self Learning

•  Task:findoutwhatisthecommandtoshufflelinesofadatafile“pet_store.csv”,thencreateafile“pet_shuffled.csv”.

•  Commands– man,-help,man-k–  Googlesearch“howtoshufflelinesinafilelinuxshell”,“randompermutaEoninlinuxshell”

•  Learn:–  Howtofindcommand–  Howtogetdetailsofacommand–  Command“shuf”

Page 62: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Exercise 7: Seft Learning

•  Task:findouthowtosortlinesofadatafile,thensortthefile“polls.csv”to“polls_sort.csv”.1.  findoutifthereisacommandcouldsort

thefile.2.  Trytosortdatafile“polls.csv”.

Note:Donotsortthefirstline!

Page 63: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Summary •  Linuxlearnt

–  Commands•  NavigaEon•  Getorcreatefiles•  Organizingfiles•  Lookintofiles•  Searchfiles•  Fileaoributes•  Onlinehelpormanual

–  Scripts•  Pipeline•  Makeyouowncommand•  Environmentofashell

Page 64: Introduction to Linux/Unix · PDF file• View the system available sobware ... Find the latest version of “w ” and module ... drwxr-xr-x 2 class0 temporary 3 Oct 12 17:06 Documents

Q & A

Thank You!