ECPE 170 –Jeff Shafer –University of the Pacific Linux...

25
ì Computer Systems and Networks ECPE 170 – Jeff Shafer – University of the Pacific Linux Basics

Transcript of ECPE 170 –Jeff Shafer –University of the Pacific Linux...

Page 1: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

ìComputer Systems and NetworksECPE170– JeffShafer– UniversityofthePacific

LinuxBasics

Page 2: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Pre-Lab

ì EveryoneinstalledLinuxontheircomputer

ì Everyonelaunchedthecommandline(“terminal”)andranafewcommands

ì Whatproblemswereencountered?ì Virtualizationsupportinprocessornotenabled(BIOS)ì VMWare Player(currentversion)onlyrunsonWindows64ì 3Dgraphicsvirtualizationincompatiblewithspecifichardwareì Oldvirtualmachinesoftwareì Others?

ì Tip:IfyouhaveproblemsmaximizingyourVMtofullscreen,ordoingcopy-and-pastebetweenLinuxandWindows,makesureyouinstalledtheVMtools

Spring2017ComputerSystemsandNetworks

2

Page 3: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Person of the Day: Linus Torvalds

ì Creatorof LinuxKernelì Startedin1991ì Firstdeveloper– hobby

project(forfun!)ì Modernkernelisproductof

workbythousandsofprogrammers

ì Currently“finalauthority”onwhatisincludedinthekernel

ì CreatorofGit versioncontrolsystemì InitiallyforLinuxkerneldev

Spring2017ComputerSystemsandNetworks

3

Page 4: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating System Tasks

ì WhatdoestheOSneedtodo?ì Scheduleprocessestorunì Memorymanagementì Interrupthandling(managehardwareingeneral)ì Security(betweenprocesses)ì Networkaccessì Storagemanagement(filesystem)ì Graphicaluserinterface

ì MaybeamiddlewarelayerontopoftheOS

Spring2017ComputerSystemsandNetworks

4

Page 5: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Processes

ì Processmanagementisakeyoperatingsystemtask

ì OSmustinitiallycreateprocesses whenyourunyourprogram

ì OScanallowprocessestoaccessresourcesì Mustschedule accesstoshared resources(e.g.,CPU)

ì OScanallowprocessestocommunicate witheachother

ì OSmustcleanupafterprocessfinishesì Deallocate resources(e.g.memory,networksockets,file

descriptors,etc…)thatwerecreatedduringprocessexecution

Spring2017ComputerSystemsandNetworks

5

Page 6: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Scheduling

ì Theoperatingsystemschedulesprocessexecutionì Whatprocessesareallowedtorunatall?ì Whatprocessesareallowedtorunrightnow?

ì ContextswitchesoccurwhentheCPUistakenfromoneprocessandgiventoanotherprocessì CPUstate(registers,currentPC,etc…)ispreserved

duringacontextswitch

Spring2017ComputerSystemsandNetworks

6

Page 7: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Scheduling

ì PreemptiveSchedulingì Eachprocessisallocatedatimeslice.ì Whenthetimeslice expires,acontextswitchoccurs

ì Acontextswitchcanalsooccurwhenahigher-priorityprocessneedstheCPU

Spring2017ComputerSystemsandNetworks

7

Page 8: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Security

ì ProcessAisforbiddenfromreading/modifying/writingthememoryofProcessBì Virtualmemory isahugehelphere!ì Eachprocesshasaseparatevirtual addressspacethat

mapstodifferentregionsofphysicalmemory

ì ProcessAhasotherlimitsbesideswhichmemorypagesitcanaccessì Whataresomeotherlimits?ì Amountofmemoryconsumedì Numberofopenfilesondiskì Whichfilesondiskcanberead/written

Spring2017ComputerSystemsandNetworks

8

Page 9: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Filesystem

ì OSisresponsibleformanagingdataonpersistentstorage

ì Jobofthefilesystem!ì Whatfilesexist?(i.e.names)ì Howaretheyorganized?(i.e.paths/folders)ì Whoownsandcanaccessthem?(i.e.usernames,

permissions)ì Whereareindividualfileblocksstoredonthedisk?

ì i.e.filename“database.dat”isreallycomposedof15823blocks,ofwhichblock1islocatedatlogicalblockaddress#...ontheharddrive.

Spring2017ComputerSystemsandNetworks

9

Page 10: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – Device Management

ì Managedevicesì HowdowesenddatatotheNICfortransmission?ì Howdowerenderanimagefordisplayonscreen?ì HowdowereadablockofdatafromourRAIDdisk

controller?

ì Operatingsystemscanbeextendedthroughdevicedrivers tomanagenewhardwareì Hardwarevendorswritesoftwaretomanagetheirdevicesì OSprovidesafixedinterface(API)thatdrivermustfollow

ì Commontaskforadevicedriverisrespondingtointerrupts(fromthatdevice)

Spring2017ComputerSystemsandNetworks

10

Page 11: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – The Kernel

ì Whodoesallthisessentialworkintheoperatingsystem?(besidestheGUI)ì Thekernel (i.e.theheartorcoreoftheOS)

ì Kernelperforms:ì Schedulingì Synchronizationì Memorymanagementì Interrupthandlingì Securityandprotection

Spring2017ComputerSystemsandNetworks

11

Page 12: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – GUI

ì Operatingsystemswithgraphicaluserinterfaces(GUI)werefirstbroughttomarketinthe1980s

AppleMacOS1.0(released1984)

MicrosoftWindows1.0(released1986)

Capturesfromhttp://www.guidebookgallery.org/screenshots

Spring2017ComputerSystemsandNetworks

12

Page 13: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Spring2017ComputerSystemsandNetworks

13

ì SignificantevolutioninGUIdesigninsubsequentdecades

Page 14: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Operating Systems – GUI

ì Technicalperspective:ì TheGUIisoneoftheleastimportantpartsofthe

operatingsystem

ì AGUIdoesnotevenhavetobepartofthetrue OSatallì Windows1.0wasjustaprogramthatranontopof

MS-DOS,thetrue operatingsystem(ofthatera)

ì Buttoauser,theGUIisoneofthemostimportantpartsoftheOS!

Spring2017ComputerSystemsandNetworks

14

Page 15: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Command-LineAdvantagesofCommandLine

AdvantagesofWindows/GUI

Spring2017ComputerSystemsandNetworks

15

Page 16: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

ìLinux Command Line

Spring2017ComputerSystemsandNetworks

16

Page 17: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Shell

ì Whatistheshell?(e.g.BASH,CSH,SH)ì Programbetweenuserandthekernelì Command-lineinterpreter

ì Parsesuserinputandcarriesoutcommands

Spring2017ComputerSystemsandNetworks

17

Page 18: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Shell Shortcuts

ì <TAB>keytoauto-completecommands

ì <UPARROW>keytocyclethroughpreviouscommands

Spring2017ComputerSystemsandNetworks

18

Thesetwotipsmakeyourlifesomucheasier!

Page 19: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Linux: Sudo Command

ì sudo <<command>>

ì Commandisrunasrootuser

ì root=“Administrator”

Spring2017ComputerSystemsandNetworks

19

http://xkcd.com/149/

Page 20: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Linux: Apt-Get Command

ì Whatisapackagemanager?ì Wheredidtheseappscomefrom?

ì apt-get <<mode>> <<options>>

ì apt-get install gedit

ì Mode=installapackageì Option=Gedit (nameofpackage)

ì MustrunasROOTtouse!ì sudo apt-get …

Spring2017ComputerSystemsandNetworks

20

Page 21: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Linux: Directory Tree

ì Absolutepath:ì /home/hpotter/thesis/intro.txt

ì Relative path:ì IfIamalreadyin/home/potter/ì addresses.html

Spring2017ComputerSystemsandNetworks

21

http://osl.iu.edu/~pgottsch/swc2/lec/shell01.html

Page 22: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

ìLabs

Spring2017ComputerSystemsandNetworks

22

Page 23: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Labs

ì Labshave(atmost)twogradedelements:

1. Pre-Lab“checkpoint”– quickverificationthatpre-labappears tobedone1. Dueatstartoffirstdayoflab

2. LabReport1. Submitallsourcecodeusedwithlabreport2. Duebyposteddateafterlab

Spring2017ComputerSystemsandNetworks

23

Page 24: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Lab Reports

ì Notreally“reports”,morelike“worksheets”

ì CreateinLibreOffice (akaOpenOffice)usingexampletemplateonwebsite

ì ExportinPDFformat

ì Submitì ViaCanvasAssignments sectionforLab1only!ì ViaVersioncontrolforLab2andbeyond

Spring2017ComputerSystemsandNetworks

24

Page 25: ECPE 170 –Jeff Shafer –University of the Pacific Linux Basicsecs-network.serv.pacific.edu/ecpe-170/slides/02linux.pdf · ì Computer Systems and Networks ECPE 170 –Jeff Shafer

Upcoming Schedule

ì Todayì Lab1– LinuxBasics

ì Thursdayì Lab2– VersionControl

ì Deadlinesì Lab2pre-labcheckpoint– StartofclassThursdayì Lab1Report– Jan28th,2017by5am

ì SubmitviaCanvasì Lab2Report– Jan30th,2017by5am

Spring2017ComputerSystemsandNetworks

25