introduction to linuxjtang/archives/cs104.s14/lectures/l03linuxintro.pdf• android ice cream...
TRANSCRIPT
Introduction to LinuxSpring 2014, Section 02, Lecture 3
Jason Tang
Topics
• What is an Operating System
• Overview of Linux
• Linux commands
• Shell
• Submit system
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”
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
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.
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
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
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)
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”
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
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”
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”
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
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
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
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)
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
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