Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel...
Transcript of Linux Introduc)on to Linux and Unix and the …on to Bioinformacs online course: IBT Linux | Amel...
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
LinuxIntroduc)ontoLinuxandUnixandthe
commandline
Introduc)ontoBioinforma)csonlinecourse:IBT
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
LearningObjec)ves
① UnderstandtheUnixfilestructure② Understandfullvsrela5vepaths:whenand
howtousethem③ Learnhowtocreatedirectoriesandnavigate
throughthefilestructure④ Learnsomeusefulshortcuts
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
LearningOutcomes
① Beabletocreateafilestructure② Beabletonavigatethroughthefilestructure③ Beabletocreatetextfilesandviewtheir
content④ Beabletousesimpleshortcuts
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Introduc)ontoLinuxandUNIX
4
Part1
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
WhatisLinux?
• UNIXisanOpera5ngSystem(OS)ini5allydevelopedinthe1960.
• There are many different versions of UNIX, thatsharecommonsimilari5es.
• Themostpopularvarie5esofUNIXareSolaris,LinuxandMacOS.
• UNIX systemshaveagraphicaluser interface (GUI)makingthemeasiertouse.
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
• Linuxisfreeandthemostpopulardistribu5onsareUbuntu,Fedora/RedHat,Mandriva,etc.
• Lowcostandverystablesystem• MostsecureOS• Bestmul5-userandmul5taskingOS• Theworld’sfastestsupercomputersrunLinux• FastdevelopingOS(manydevelopers)
VerypopularasserversOS
7
WhyLinux?
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Linuxdistribu)ons
• DifferentLinuxdistribu5onsareavailablehap://distrowatch.com/
• Ubuntudistribu5oniseasyandconvenienttouseforbeginners
• AsimpleguidetoinstallUbuntuinyourmachine:hap://www.ubuntu.com/download/desktop/install-ubuntu-desktop
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Adaptedfrom:www.usna.edu
AccessibleviatheTerminal
Thecoreopera)ngsystem
ProgramsandsoJwares
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
10
TheTerminal
• Aterminalreferstoawrapperprogramwhichrunsashell
• TherearemanydifferentUnixshells,themostpopularshellforinterac5veuseincludeBash:thedefaultonmostLinuxinstalla5ons
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
ShellpromptMachinename
Username Eventhoughitisacommandlineinterface,themouseiss5llhandy(scroll,copy,paste,etc.)
11
TheTerminal
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
File-systemunderUNIX
12
Part2
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
home
Watson
Desktop Documents IBT2017
Linux
Session1 Session2
Genomics
file1 file2
Directoriesfiles
14
fileX
Ordinaryfiles
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
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
~(yourhomedirectory)
• ~referstothehomedirectoryinagivenfilesystem
• The5lde~charactercanbeusedtospecifypathsstar5ngatyourhomedirectory
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Absoultepath?/
home
Watson
Desktop Documents IBT2017
Linux
Session1 Session2
Genomics
file1 file2
Thefullpathtofile1is:/home/Watson/IBT2017/Linux/Session1/file1
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Everydirectoryhastwospecialsub-directories:
u . (dot): thecurrentdirectory
u .. (dot-dot): theparentdirectory
IBT2017
Genomics Linux
Session2Session1
. ..
20
RefertotheparentandcurrentdirectoriesRefertotheparentandcurrent
directories
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?
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Firsttestoftheterminal
• OpentheTerminalonyoursystem• Theshellpromptwillappear
Ok,let’strysometyping!
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Crea)ngdirectoriesandnaviga)ngthroughthefilestructure
Part3
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Commandsformanipula)ngdirectories
mkdir Makedirectory:createsanewdirectory
rmdir Removesadirectory
pwd Displaystheabsolutepathofthecurrentworkingdirectory
cd Changedirectory:allowsmovingfromonedirectorytoanother
ls Listsadirectorycontent
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
pwdcommand
• pwd:printworkingdirectory• Displaystheabsolutepathofyourcurrentloca5oninthefilesystem
• Trypwdonyourterminal• Youshouldsee:/home/YourUsername
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
lscommand
• lsliststhecontentofthecurrentdirectorybydefault
• Commandstructurels[OPTION][dirname]• Someusefulop5ons:
• -l:showssizes,modifieddateand5me,fileorfoldernameandowneroffileandpermissions• -a:Listallfilesincludinghiddenfilestar5ngwith‘.’• -lh:showssizesineasierreadableformat• -R:recursivelylistssub-directories• -lS:sor5ngbyfilesizes
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Createadirectory
• mkdir:makesadirectory• Commandstructure:mkdirdirname[path]
• mkdirdirname:wouldcreateadirectorywiththespecifieddirname
• Thenewcreateddirectorywillbecreatedinyourcurrentworkingdirectory
• Ifyouwanttocreateitelsewhere,youhavetospecifythepath:mkdirdirnamepath
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Commandsbasicstructure
command[–op5ons][arguments]Example:
ls–lh/home/Watson/IBT2016 pwd mkdirTest1
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.)
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Moveinthefilessystem
• cd:changetheworkingdirectory• Commandstructure:cd<path>
• Thepathnameofthedirectoryyouwanttomovetoshouldbespecified
• Youcanspecifyeithertheabsolutepathortherela5vepath
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Removeadirectory
• rmdir:removesadirectory• Commandstructure:rmdirdirname[path]• Itwouldremovethedirnamedirectory• Thedirectoryshouldbeinyourcurrentworkingdirectory
• Ifyouwanttoremoveitfromelsewhere,youhavetospecifythepath:rmdirdirnamepathtothedirectory
• rmdirworksifthereisnocontentsinthedirectory
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Removeadirectory
• rmdirworksifthereisnocontentsinthedirectory
• Ifthedirectorycontainsfilesorsub-directories,anerrormessagewillappear:“Directorynotempty”
• Thereisanop5ontoremove-r,whichstandsforrecursive,thatwillrecursivelyremoveadirectoryanditscontents
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Howtogethelpforacommandfromtheterminal?
• mancommandnamedisplays
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Part4
SomeusefulshortcutsandLinks
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
UsefulLinks
• cd:cdfollowedbynothingwillchangetheworkingdirectorytoyourhomedirectory
• cd~user_name:movestothespecifieduserhomedirectory
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
Introduc)ontoBioinforma)csonlinecourse:IBTLinux|AmelGhouila
Thanks
• ShaunAron&SumirPanji