Lec1: Course Overview and Getting Started

advertisement
CS197U: A Hands on Introduction to Unix
Lecture 1: Course Overview and Getting Started
Tian Guo University of Massachusetts Amherst – College of Information and Computer
Sciences
http://www.cs.umass.edu/~tian/197U/
1
Important info
•  Instructor
•  Tian Guo -- tian@cs.umass.edu
•  Lectures (11 classes)
•  Tuesday & Thursday 4:00 - 5:00
•  No class on 10/13/2015
For the next 6 weeks only!
09/15/15 - 10/22/15
•  Reserved Edlab time •  Thursday 1:00 – 3:00
•  Textbook: Unix and Linux: Visual QuickStart Guide (4th Edition)
•  by Deborah S. Ray, Eric J. Ray. •  Required (5th edition ebook is available on Umass Library) •  Class Website: http://www.cs.umass.edu/~tian/197U
2
Course topics
•  We will cover:
What is Unix/Linux?
Basic overview of Unix/Linux
Command line basics
Important tools
Getting remote files
Editing and manipulating files
Operating System organization
File system layout
Processes
Your Own Copy of Linux
Popular Linux distributions
Running Linux in a virtual
machine
Configuring the system
Basic system
administration
Installing applications
Programming in Linux
Compiling C/C++ files
Simple shell scripting
Other Useful Stuff
File processing
Using subversion
Configuring bash basics
3
Class structure
•  Lectures: 45-60 minutes on the day s topic
•  Lab time: EDLAB is reserved for two hour before Thursday class (1:00 – 3:00)
•  LGRT Room 223/225 - door is locked
•  I ll be there to answer questions
•  Assignments
•  7 Assignments, posted on website •  Always due at 3:45pm on due date (or as specified on website)
•  Class Attendance is monitored
•  5 points for attending all classes
•  A point will be deducted for each missing class. 4
Class structure
•  Grading: Pass / Fail only
•  Each assignment accounts for 10 points •  6 of 7 assignments must be turned in •  Choose which assignment you want to skip
•  Email me by the due date if you decide to skip an assignment
•  If you turn in 7 assignments, the best 6 will be counted
•  Late assignments are 0 points
•  To pass
•  Submit 6 assignments
•  Total of 45 points (6 assignments + class attendance)
•  No additional late assignments will be accepted for credit •  No incompletes, unless you have a note from a doctor
•  Ask if you have any questions about these policies
5
Class Structure
•  Withdrawal from class
•  only possible September 25
•  Special policy since class is so short
•  Reading
•  Optional Readings for each class posted on website
•  Includes additional commands and tips not covered in class
•  Moodle will be used for
•  Assignments and Grades
•  (Syllabus)
•  Piazza will be used for assignment questions and course discussions 6
And finally…
•  Email List
•  Announcements may be sent to UMass student email account
•  Please fill out our Online Survey:
•  Linked from course website
•  A few questions about your background and what you want to learn from
the course
•  Last but not least
•  Please no laptops and cell phones in class*
•  Printed slides and notes are fine
•  This class is hands-on, so listen and learn in class
•  Practice what you learn at home
*You are excused in case of disabilities – let me know
7
This Class
•  Note: This course is designed for beginners!!
•  All material should be doable with NO prior knowledge
•  We will try to throw in a few advanced tips and tricks to keep everyone
interested
•  The goal of this class is to introduce you to tools you might need in the future
as a computer science major
•  We want to introduce you to a wide variety of commands and tools so you
know that they exist and can look them up later, even if you don t
remember exactly how to use them
•  If you don t understand how something works or how/why you would use
it- Please Ask!
8
Outline for Today s Lecture
•  Overview and brief history of Linux
•  Using a Linux System
•  Description of Assignment 1
9
Operating system fundamentals
•  An operating system manages resources
Applications
•  CPU, RAM, disks, network, etc
•  Provides an environment to run applications
Operating System
•  Grants resources to applications
•  Provides system calls and device drivers
Hardware
•  Separates applications and users
•  For security and performance
•  OS is more than just the interface you see when you start your computer
•  The window manager is just a pretty application you interact with
•  Examples: Microsoft Windows 7, Mac OS X, Linux
10
Unix
•  In the 1960 s, computing tasks became more complex
•  More than one user at a time
•  More than one task at a time
•  Unix was developed as a multi-user, multi-tasking operating system
•  Developed by employees including Ken Thompson and Dennis Ritchie
from Bell Labs in 1969
•  From UNIX came a number of UNIX-like operating systems
•  SYS V and BSD (1978)
•  UNIX is a commercial OS, primarily for servers and mainframes
•  The code is proprietary, and costs lots of $$$
11
Linux
•  Linux is an open source UNIX implementation
started in 1991
UNIX
•  Open source: the code is freely available for
anyone to download, look through, edit,
change, etc
•  Incorporates ideas from both SYSV and BSD
•  LINUX was designed for the x86 (ie common
desktops/laptops)
SYSV
BSD
•  It is used for both running commercial servers
and on desktops and laptops
•  The code is freely available and maintained by
volunteers
Linux
12
Linux
•  There are many different Linux distributions to choose from
•  Include different combinations of window managers, utilities, package
managers, etc.
•  Ubuntu is a specific distribution that has become quite popular
•  Ubuntu is the distribution we will use in the Edlab
•  Linux is not the only unix-like OS
•  Others: Solaris, FreeBSD, Mac OS X
•  In this class:
•  The general ideas will apply to either OS
•  The systems we actually use will be Linux
13
Linus Torvalds
•  Started the Linux kernel while a Masters
student in Finland in 1991
•  Kernel is the main control program for the OS
•  Fun Fact: About 2% of the current Linux code
was written by him
•  At time of release, he didn t know it would become so popular •  Message with the first Linux release:
•  PS.... It is NOT portable (uses 386 task switching etc), and it probably
never will support anything other than AT-harddisks, as that's all I
have :-( •  Now supports pretty much any hardware platform...
14
GNU
•  Recursive acronym
•  GNU s Not Unix
•  Started in 1984 to develop a fully free Unix-like operating system
•  Later adopted Linus Torvald s Linux kernel •  Combined kernel with basic system utilities: shells, compilers, editors, etc
•  Makes much of the software typically included in Linux
•  Committed to FREE software
•  Freedom to: run, copy, change, distribute
•  What we refer to as Linux is really GNU/Linux 15
Unix/Linux Review
•  The term Unix refers to a multi-user multi-tasking operating system
•  There are many different versions of Unix, developed by different groups
•  Linux is one version
•  Open-source, free version of Unix •  There are many different Linux distributions to choose from
•  Ubuntu is a specific distribution that has become quite popular
16
What does it look like?
17
What does it look like?
•  It is more than just a command line, but in these classes we will focus on that
•  We will focus on how to connect to linux machines remotely since you will
probably need to do that for a class in the future
•  How to use the command line to do everything you need to
•  What commands to use to find the information you need
18
Outline for Today s Lecture
•  Overview and brief history of Linux
•  Using a Linux System
•  Description of Assignment 1
19
Accessing a Linux system
•  Option 1: Walk to the Edlab
•  All the Macs can triple boot - choose between Windows, OS X, or Linux
•  Option 2: Remote login with Secure Shell (SSH)
•  Utility to connect to remote servers
•  Can run commands, copy files, etc
•  Requires account on remote server
•  Provides a secure, encrypted connection
•  Requires SSH client
20
Using SSH to reach the edlab (Windows)
•  Putty is a free SSH client
•  Single file to download, just
run putty.exe
•  Lots of options available
(generally unnecessary)
•  Hostname is name of server
Windows SSH Utilities
Putty
- Free for everyone
http://www.chiark.greenend.org.uk/~sgtatham/putty/
SecureCRT
- Free from UMass OIT
http://www.oit.umass.edu/software/securecrt
21
Using SSH to reach the edlab (Mac Os X)
•  Open Terminal and type ssh
hostname
22
Edlab SSH Server Info
•  We will use servers in the Edlab for remote access
•  Uses your ordinary OIT account for username
•  Default password is EL###xxx
•  ### = last 3 of Student ID Number
•  xxx = first 3 of username
•  Example:
•  Joe Smith
•  OIT username: jsmith
•  Student ID: 1234567
•  Edlab password: EL567jsm
Edlab SSH Info
Hostname: elnux#.cs.umass.edu
# = 1, 2, 3, 4 or 7
Username: same as OIT acct
Password: EL###xxx
where:
### = last 3 of Student ID Number
xxx = first 3 of username
•  Edlab Website: www-edlab.cs.umass.edu
23
Verifying SSH Server identity
•  Must verify server identity the first time you connect
The authenticity of host 'elsrv4
(128.119.41.100)' can't be establishedbut keys
of different type are already known for this
host.RSA key fingerprint is f8:81:35:02:54:6b:
53:11:a3:9b:7f:ed:12:86:02:be.Are you sure you
want to continue connecting (yes/no)? yes
•  Every server has a unique RSA fingerprint
•  Generally can trust that server is correct, so just type yes •  Only will ask the first time you connect to the server, or if server changes
24
Some terminology
•  Command line = Shell = Terminal (approximately)
•  Terminal runs a Shell which displays a Command line (technically)
•  Terminal or Console
•  an interactive window that displays text
•  Shell
•  the most basic program run inside the terminal
•  accepts and interprets your input
•  can split off new processes to run your commands
•  Command Line
•  the prompt where you enter the commands you want to run
25
Our first command line
•  Type a command, hit [Enter]
•  Use [Up] and [Down] to cycle through past commands
Prompt
elnux7> command
elnux7> ls note.txt public_html results
elnux7> pwd /nfs/elsrv4/users4/grad/twood Basic Commands
ls =
list the contents of a directory
pwd =
print current directory location
cd <folder> =
change directory
cp <src file> <dest file> =
rm <file> =
copy
remove (delete)
touch <file> =
create an empty file
26
Anatomy of a command
•  Executable: program name you want to run
•  ls # list files in the current directory
•  Flags: options for the command
•  ls -­‐l # show a long list with extra details •  Arguments: additional parameters, or input for the command
•  ls -­‐l public_html # list the contents of the directory public_html •  More examples:
•  cd public_html # change to public_html folder
•  cd .. # move back one level in the folder tree
•  cd home folder
# (no argument) change directly to your
27
Looking around the system
File Structure
•  You log into your home directory •  Private space for your own files
•  Limited space!
•  Contains several subdirectories
/courses/cs100/cs197u/
abrd
acojoe
....
•  cs197u/ - a link to your course
specific home directory
cs197u
•  public_html/ - directory for placing
web content
yuantu
....
other"
users
main course"
files
/courses/cs100/cs121/
....
....
other
courses
28
Demo
29
The most useful thing to learn in this class
•  The absolute most useful thing to learn in this class...
•  Is just a single key on the keyboard.
•  Any guesses?
•  The tab key will auto complete a command or file name
•  Start typing a line, then hit tab to finish it for you
•  Prevents typos
30
Some command line tips
•  Press <tab> to auto complete a program, file, or folder name
elnux7> elnux7> cd /courses/cs100/cs19 elnux7> cd /courses/cs100/cs19 cs191a.lehnert cs191p/ cs192s/ cs197c/ cs197u/ elnux7> cd /courses/cs100/cs19 elnux7> cd /courses/cs100/cs197u Press
<tab>
•  Type history to show a list of commands you have run recently
•  Press <ctrl-c> to cancel what you have typed, or quit (some) programs
•  Use UP and DOWN to scroll through recently run commands
31
What can you do now?
•  Probably cannot break the edlab (sorry!)
•  but you could mess up your own stuff...
•  Unix has strong security controls separating ordinary users from
administrators (and from each other)
•  We will learn more about this later
•  But you can....
•  Create and browse files within your home directory and your course
specific home directory
32
Outline for Today s Lecture
•  Overview and brief history of Linux
•  Using a Linux System
•  Description of Assignment 1
33
Assignment 1
DUE Tue 09/22 @3pm
•  Connect to the Edlab with SSH •  or walk there during office hour •  Log into your account and change your password
•  Use the passwd command
•  Don t forget your new one!
•  Look around your home directory
•  Use ls, pwd, and cd
•  Browse the cs197u/ directory
submit your
work
•  Create a new file in your course specific home directory to show me that you
could log on and use basic commands
•  More instructions on assignment web page
34
Lecture 1 cheat sheet
Command
Description Parameters
ssh connect to a remote host
ssh user@name.cs.umass.edu passwd change account password
change directory
cd <folder> cd .. # go back cd #go home ls list directory contents
ls <folder> ls -­‐l ls -­‐l –a (shorter: ls -­‐la) pwd print working (current) directory
touch create an empty file
cd touch <filename> 35
Download