+ All Categories
Home > Documents > Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel...

Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel...

Date post: 23-Mar-2018
Category:
Upload: vuongtram
View: 220 times
Download: 4 times
Share this document with a friend
38
Introduc)on to Bioinforma)cs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinforma)cs online course: IBT
Transcript
Page 1: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

LinuxIntroduc)ontoLinuxandUnixandthe

commandline

Introduc)ontoBioinforma)csonlinecourse:IBT

Page 2: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

LearningObjec)ves

① UnderstandtheUnixfilestructure② Understandfullvsrela5vepaths:whenand

howtousethem③ Learnhowtocreatedirectoriesandnavigate

throughthefilestructure④ Learnsomeusefulshortcuts

Page 3: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

LearningOutcomes

① Beabletocreateafilestructure② Beabletonavigatethroughthefilestructure③ Beabletocreatetextfilesandviewtheir

content④ Beabletousesimpleshortcuts

Page 4: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Introduc)ontoLinuxandUNIX

4

Part1

Page 5: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

WhatisLinux?

•  UNIXisanOpera5ngSystem(OS)ini5allydevelopedinthe1960.

•  There are many different versions of UNIX, thatsharecommonsimilari5es.

•  Themostpopularvarie5esofUNIXareSolaris,LinuxandMacOS.

•  UNIX systemshaveagraphicaluser interface (GUI)makingthemeasiertouse.

Page 6: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

LinuxvsUnix

•  Linux is a “clone” of the original Unix but doesn’tcontainitscode

•  Linux is free and open source, the original Unix isnot(butsomeofitsderiva5vesare)

•  Allcommandlinesworkthesameonboth

Page 7: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

•  Linuxisfreeandthemostpopulardistribu5onsareUbuntu,Fedora/RedHat,Mandriva,etc.

•  Lowcostandverystablesystem•  MostsecureOS•  Bestmul5-userandmul5taskingOS•  Theworld’sfastestsupercomputersrunLinux•  FastdevelopingOS(manydevelopers)

VerypopularasserversOS

7

WhyLinux?

Page 8: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Linuxdistribu)ons

•  DifferentLinuxdistribu5onsareavailablehap://distrowatch.com/

•  Ubuntudistribu5oniseasyandconvenienttouseforbeginners

•  AsimpleguidetoinstallUbuntuinyourmachine:hap://www.ubuntu.com/download/desktop/install-ubuntu-desktop

Page 9: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Adaptedfrom:www.usna.edu

AccessibleviatheTerminal

Thecoreopera)ngsystem

ProgramsandsoJwares

Page 10: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

10

TheTerminal

•  Aterminalreferstoawrapperprogramwhichrunsashell

•  TherearemanydifferentUnixshells,themostpopularshellforinterac5veuseincludeBash:thedefaultonmostLinuxinstalla5ons

Page 11: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

ShellpromptMachinename

Username Eventhoughitisacommandlineinterface,themouseiss5llhandy(scroll,copy,paste,etc.)

11

TheTerminal

Page 12: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

File-systemunderUNIX

12

Part2

Page 13: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

home dev bin etc Configura5onfiles

Devicefiles

Usershomedirectories

Essen5alusercommandsbinaries

Rootdirectoryoftheen5refilesystem

WatsonCrick

Desktop Documents

Sanger

IBT2017

Linux

Session1 Session2

Genomics

Wastsonfiles

13

Linuxfilesstructure

Page 14: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

home

Watson

Desktop Documents IBT2017

Linux

Session1 Session2

Genomics

file1 file2

Directoriesfiles

14

fileX

Ordinaryfiles

Page 15: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Homedirectoryandworkingdirectory

•  When you first log in on aUNIX system, theworkingdirectoryisyourhomedirectory.

•  Whileworkingyouwillbeassociatedtoonedirectorycalledtheworkingdirectoryorthecurrentdirectory

•  An abbrevia5on of theworking directory is displayedaspartofthepromptonyourterminal

•  The command pwd gives the absolute path of theworkingdirectory

Page 16: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Whatisapathorapathname?

•  A path locates a given file in the systemhierarchy

•  Anabsolutepath in thefile systemhierarchyforagivenfileorfolderdescribestheparentsallthewayuptotheroot

•  A rela5ve path describes the path to the filestar5ngfromthecurrentworkingdirectory

Page 17: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

~(yourhomedirectory)

•  ~referstothehomedirectoryinagivenfilesystem

•  The5lde~charactercanbeusedtospecifypathsstar5ngatyourhomedirectory

Page 18: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Absoultepath?/

home

Watson

Desktop Documents IBT2017

Linux

Session1 Session2

Genomics

file1 file2

Thefullpathtofile1is:/home/Watson/IBT2017/Linux/Session1/file1

Page 19: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Absoultepath?/

home

Watson

Desktop Documents IBT2017

Linux

Session1 Session2

Genomics

file1 file2

/

/home

/home/Watson

/home/Watson/IBT2017

/home/Watson/IBT2017/Linux

/home/Watson/IBT2017/Linux/Session1

/home/Watson/IBT2017/Linux/Session1/file1

Page 20: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Everydirectoryhastwospecialsub-directories:

u . (dot): thecurrentdirectory

u .. (dot-dot): theparentdirectory

IBT2017

Genomics Linux

Session2Session1

. ..

20

RefertotheparentandcurrentdirectoriesRefertotheparentandcurrent

directories

Page 21: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

/

home

Watson

Desktop Documents IBT2017

Linux

Session1 Session2

Genomics

file1 file2

./Linux

./Linux/Session1

./Linux/Session1/file1

Currentworkingdirectory

. referstothecurrentdirectory

21

RefertotheparentandcurrentRela)vepath?

Page 22: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Firsttestoftheterminal

•  OpentheTerminalonyoursystem•  Theshellpromptwillappear

Ok,let’strysometyping!

Page 23: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Crea)ngdirectoriesandnaviga)ngthroughthefilestructure

Part3

Page 24: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Commandsformanipula)ngdirectories

mkdir Makedirectory:createsanewdirectory

rmdir Removesadirectory

pwd Displaystheabsolutepathofthecurrentworkingdirectory

cd Changedirectory:allowsmovingfromonedirectorytoanother

ls Listsadirectorycontent

Page 25: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

pwdcommand

•  pwd:printworkingdirectory•  Displaystheabsolutepathofyourcurrentloca5oninthefilesystem

•  Trypwdonyourterminal•  Youshouldsee:/home/YourUsername

Page 26: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

lscommand

•  lsliststhecontentofthecurrentdirectorybydefault

•  Commandstructurels[OPTION][dirname]•  Someusefulop5ons:

•  -l:showssizes,modifieddateand5me,fileorfoldernameandowneroffileandpermissions•  -a:Listallfilesincludinghiddenfilestar5ngwith‘.’•  -lh:showssizesineasierreadableformat•  -R:recursivelylistssub-directories•  -lS:sor5ngbyfilesizes

Page 27: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Createadirectory

•  mkdir:makesadirectory•  Commandstructure:mkdirdirname[path]

•  mkdirdirname:wouldcreateadirectorywiththespecifieddirname

•  Thenewcreateddirectorywillbecreatedinyourcurrentworkingdirectory

•  Ifyouwanttocreateitelsewhere,youhavetospecifythepath:mkdirdirnamepath

Page 28: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Commandsbasicstructure

command[–op5ons][arguments]Example:

ls–lh/home/Watson/IBT2016 pwd mkdirTest1

Page 29: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

WhatyoushouldknowaboutfilenamesinLinux

•  No real dis5nc5on between the names ofordinaryfilesandthenamesofdirectoryfiles.

•  No twofiles in the samedirectory canhave thesamename.

•  Files in different directories can have the samename.

•  Linux is case-sensi5ve: Sanger, sanger andSANGERaredifferentandwouldrepresentthreedis5nctfiles.

•  In most cases, file extensions are op5onal(.txt,.exe,etc.)

Page 30: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Moveinthefilessystem

•  cd:changetheworkingdirectory•  Commandstructure:cd<path>

•  Thepathnameofthedirectoryyouwanttomovetoshouldbespecified

•  Youcanspecifyeithertheabsolutepathortherela5vepath

Page 31: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Moveinthefilessystem:example

/

home

Watson

IBT2017Currentworking

directory

•  MovetoWatsondirectory

1.  cd/home/Watson2.  cd../..3.  cd..+cd..

•  MovetoGenomicsdirectory

1.  cd/home/Watson/IBT2017/Genomics2.  cd../Genomics3.  cd..+cdGenomics

LinuxGenomics

Page 32: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Removeadirectory

•  rmdir:removesadirectory•  Commandstructure:rmdirdirname[path]•  Itwouldremovethedirnamedirectory•  Thedirectoryshouldbeinyourcurrentworkingdirectory

•  Ifyouwanttoremoveitfromelsewhere,youhavetospecifythepath:rmdirdirnamepathtothedirectory

•  rmdirworksifthereisnocontentsinthedirectory

Page 33: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Removeadirectory

•  rmdirworksifthereisnocontentsinthedirectory

•  Ifthedirectorycontainsfilesorsub-directories,anerrormessagewillappear:“Directorynotempty”

•  Thereisanop5ontoremove-r,whichstandsforrecursive,thatwillrecursivelyremoveadirectoryanditscontents

Page 34: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Howtogethelpforacommandfromtheterminal?

•  mancommandnamedisplays

Page 35: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Part4

SomeusefulshortcutsandLinks

Page 36: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

UsefulLinks

•  cd:cdfollowedbynothingwillchangetheworkingdirectorytoyourhomedirectory

•  cd~user_name:movestothespecifieduserhomedirectory

Page 37: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Linux,someusefulCLIkeycombina)ons

•  Ctrl+A:movethecursortothebeginningofthecommandline

•  Ctrl+C:endarunningprogramandreturntotheprompt

•  Ctrl+D:logoutfromthecurrentshellsession:equivalenttoexit

•  Tab:autocompleteafilename•  TabTab:displayscommandcomple5onpossibli5es

•  Ctrl+L:cleartheterminal

Page 38: Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel Ghouila Linux Introduc)on to Linux and Unix and the command line Introduc)on to Bioinformacs

Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila

Thanks

•  ShaunAron&SumirPanji


Recommended