introduction to linuxjtang/archives/cs104.s14/lectures/l03linuxintro.pdf• android ice cream...

18
Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Upload: others

Post on 25-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Introduction to LinuxSpring 2014, Section 02, Lecture 3

Jason Tang

Page 2: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Topics

• What is an Operating System

• Overview of Linux

• Linux commands

• Shell

• Submit system

Page 3: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

What is an Operating System?

• Special type of computer program

• Controls CPU, I/O, memory, and other devices

• Controls how other programs work together

• First program run when computer turns on

• Often referred to as simply “OS”

Page 4: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Consumer Operating Systems

• Microsoft: Windows Vista, Windows 7, Windows 8

• Apple: Mac OS X 10.7, 10.8, Mavericks

• iOS 5, 6, 7

• Linux: 2.6, 3.10, 3.13

• Android Ice Cream Sandwich, Jelly Bean, Kit Kat

Page 5: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

What does an OS do?

• Provides a uniform user interface

• “Abstracts” hardware from user

• [Almost] same user interface regardless of iPhone or iPad

• Handles user interactions

• Mouse click, keyboard press, touch, gesture, etc.

Page 6: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

What else does an OS do?

• Presents a uniform interface to software

• “Hardware abstraction layer” (HAL)

• Program written for Windows 7 will [usually] run same on a Dell laptop versus a HP desktop

• Note: same hardware can run different OSs (though still only one at a time [mostly true])

• Lab computer runs Windows or Linux

Page 7: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Linux command line

• Command line when logging in to Linux via Terminal/TeraTerm Pro/Putty

• User prompt is shown, something that looks like:

linux1[1]% _

Name of Linux server you are on; “linux1”,

“linux2”, etc. are

Number in brackets is the “number” of command

you are about to run

Page 8: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Files

• In Linux, “everything is a file”

• Programs, documents, MP3s, movies, and more

• Consists of a sequence of bytes

• Files that contain other files are directories (aka folders)

Page 9: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Linux Filenames

• In Linux, all files must have a filename

• Filenames can have spaces, hyphens, underscores, most other special symbols

• For this class, just use letters, numbers, underscores (“_”), and/or dot (“.”) characters

• Linux filenames are “case sensitive”

Page 10: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Directories

• Directories contain zero or more other files

• Ergo, directories may contain other subdirectories

• Directories organized hierarchical in tree

• Parent directory is holder of subdirectories

• Use Linux command ls (stands for “list”) to display contents of your directory

• Files within same directory must have unique

Page 11: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Creating Files

• Use a text editor to create human-readable files

• For this class, use the nano program to create and modify files

• (Other text editors exist; talk to me if interested)

• Usage: nano filename

This is a “command line argument”

Page 12: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Manipulating Files

• Use cp (stands for copy) to duplicate a file

• Use rm (stands for remove) to permanently delete a file

• Need help?

• Look up things via man (stands for manual) like so: man cp

• Most commands have a “--help” argument Arguments that begin with a dash are called “flags”

Page 13: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Shell

• Program in to which you are typing commands (ls, cp, exit, etc.)

• When you log in to Linux, it starts a shell for you• Different shells exist• Can be programmed to do complex tasks

Page 14: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Subdirectories

• Your home directory is your initial location after log in

• Current directory is where you are currently located

• Use command cd (stands for change directory) to enter a subdirectory

• Use command “cd ..” to go up a directory

That’s “c”, “d”, a space, then two dots in a row

Page 15: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Paths

• Use command pwd (stands for present working directory) to display name of your current directory

• Forward-slash symbol (“/”) separates components of a path

• Topmost directory, simply “/”, is root directory

• Each running program has a current working directory

Page 16: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Common Linux Shell Commands

• ls - list files

• cp - copy file

• rm - remove file

• man - look up something in the manual

• pwd - display present working directory

• cd - change directory

• exit - exits shell (and thus logs you off system)

Page 17: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Submit Command

• Use “submit cs104_jtang assignment filename” to submit filename for a given assignment

• Run submitls to view your submission

• Run submitrm to remove a file from your submission

Page 18: Introduction to Linuxjtang/archives/cs104.s14/lectures/L03LinuxIntro.pdf• Android Ice Cream Sandwich, Jelly Bean, Kit Kat. What does an OS do? • Provides a uniform user interface

Practice Using Submit• Use nano to create a file named “hw0.txt”

• Enter your name, and then the two commands that will remove old files you no longer need

• Save, then exit

• Submit this file, then confirm your submission, like so:

• You earned an extra credit point for today!

submit cs104_jtang hw0 hw0.txt submitls cs104_jtang hw0