35
1 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/

CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

1

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/

Page 2: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Important info

•  Instructor •  Tian Guo -- [email protected]

•  Lectures (11 classes) •  Tuesday & Thursday 4:00 - 5:00 •  No class on 10/13/2015

•  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

For the next 6 weeks only!

09/15/15 - 10/22/15

2

Page 3: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 4: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 5: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 6: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

•  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

Class Structure

6

Page 7: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

7 *You are excused in case of disabilities – let me know

Page 8: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 9: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Outline for Today’s Lecture

•  Overview and brief history of Linux

•  Using a Linux System

•  Description of Assignment 1

9

Page 10: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Operating system fundamentals

•  An operating system manages resources

•  CPU, RAM, disks, network, etc

•  Provides an environment to run applications

•  Grants resources to applications

•  Provides “system calls” and device drivers

•  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

Applications

Operating System

Hardware

10

Page 11: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 12: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Linux

•  Linux is an open source UNIX implementation started in 1991

•  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)

•  It is used for both running commercial servers and on desktops and laptops

•  The code is freely available and maintained by volunteers

UNIX

SYSV BSD

Linux

12

Page 13: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 14: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Linus Torvalds

•  Started the Linux kernel while a Mastersstudent in Finland in 1991

•  Kernel is the main control program for the OS

•  Fun Fact: About 2% of the current Linux codewas 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

Page 15: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 16: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 17: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

What does it look like?

17

Page 18: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 19: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Outline for Today’s Lecture

•  Overview and brief history of Linux

•  Using a Linux System

•  Description of Assignment 1

19

Page 20: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 21: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 22: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Using SSH to reach the edlab (Mac Os X)

•  Open Terminal and type ssh hostname

22

Page 23: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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 Website: www-edlab.cs.umass.edu

Edlab SSH Info Hostname: elnux#.cs.umass.edu# = 1, 2, 3, 4 or 7Username: same as OIT acctPassword: EL###xxx where: ### = last 3 of Student ID Number xxx = first 3 of username

23

Page 24: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Verifying SSH Server identity

•  Must verify server identity the first time you connect

•  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

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

24

Page 25: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 26: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Our first command line

•  Type a command, hit [Enter]

•  Use [Up] and [Down] to cycle through past commands

elnux7>        elnux7>  ls  note.txt    public_html      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>  = copy rm  <file>  = remove (delete) touch  <file>  = create an empty file

Prompt

command

results

26

Page 27: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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     # (no argument) change directly to your home folder

27

Page 28: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Looking around the system

•  You log into your “home directory” •  Private space for your own files

•  Limited space!

•  Contains several subdirectories

•  cs197u/ - a link to your course specific home directory

•  public_html/  - directory for placing web content

File Structure /courses/cs100/cs197u/

abrd

acojoe

....

cs197u

....

yuantu

/courses/cs100/cs121/

....

....

other"users

main course"files

other courses

28

Page 29: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Demo

29

Page 30: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 31: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Some command line tips

•  Press <tab> to “auto complete” a program, file, or folder name

•  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

elnux7>  

31

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/cs19                  cs191a.lehnert    cs191p/                  cs192s/                  cs197c/                  cs197u/                    elnux7>  cd  /courses/cs100/cs197u  

Press <tab>

Page 32: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

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

Page 33: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Outline for Today’s Lecture

•  Overview and brief history of Linux

•  Using a Linux System

•  Description of Assignment 1

33

Page 34: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Assignment 1

•  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

•  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

DUE Tue 09/22 @3pm

“submit” your work

34

Page 35: CS197U: A Hands on Introduction to Unixtian/197U/materials/lecture... · 2015-09-14 · Class structure • Grading: Pass / Fail only • Each assignment accounts for 10 points •

Lecture 1 cheat sheet

Command Description Parameters

ssh   connect to a remote host ssh  [email protected]  

passwd   change account password

cd   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 touch  <filename>  35