391 Lecture 01
391 Lecture 01
Lecture 1
introduction to Linux/Unix environment
slides created by Marty Stepp, modified by Jessica Miller, Ruth Anderson, and Brett Wortzman
http://www.cs.washington.edu/391/
1
Lecture summary
• Course introduction and syllabus
2
Course Introduction
• Instructor:
Brett Wortzman, brettwo@cs, CSE446
Office hours: TBD
Website: http://cs.washington.edu/391
3
Course Topics
• Linux command line interface (CLI)
• Shell commands
• Users and groups
• Permissions
• Shell scripting
• Regular expressions
• Project management tools (e.g. makefiles)
• Version control (e.g. git)
4
Homework/Grading
• ~Nine weekly assignments
Released after lecture
Due following Tuesday, 11:59pm (no late work accepted)
• Based on material covered in that week’s lecture
A few “self-discovery” extensions
All required information in lecture, slides, book, and/or man pages
• Graded out of 2 points each
Primarily determined by effort/completion (see syllabus)
Total of 14 points required to receive credit
• To be completed on Linux/Unix systems (next slide)
• Collaboration allowed/encouraged, but ALL SUBMITTED WORK
MUST BE YOUR OWN
5
Accessing Linux/Unix
Roughly in suggested order…
•ssh to attu (CSE majors), linuxNN (EE majors), or ovid (all UW
students)
•Download/run CSE VM
•Visit CS or EE basement labs
•Set up Linux on your own machine
6
Operating systems
• What is an OS? Why have one?
• What is a Kernel?
7
Operating systems
• operating system: Manages activities and resources of a computer.
software that acts as an interface between hardware and user
provides a layer of abstraction for application developers
8
Unix
• brief history:
Multics (1964) for mainframes
Unix (1969)
K&R
Linus Torvalds and Linux (1992)
11
Things you can do in Linux
• Load the course web site in a browser
• Play MP3s
• Edit photos
• IM, Skype
12
Shell
• shell: An interactive program that uses user input to manage the
execution of other programs.
A command processor, typically runs in a text window.
User types commands, the shell runs the commands
Several different shell programs exist:
• bash : the default shell program on most Linux/Unix systems
• We will use bash
• Other shells: Bourne, csh, tsch
13
Why use a shell?
• Why should I learn to use a shell when GUIs exist?
faster
work remotely
programmable
customizable
repeatable
14
Example shell commands
command description
pwd print the current working directory
cd changes the working directory
ls lists files in a directory
man brings up the manual for a command
exit logs out of the shell
$ pwd
/homes/iws/rea
$ cd CSE391
$ ls
file1.txt file2.txt
$ ls –l
-rw-r--r-- 1 rea fac_cs 0 2017-03-29 17:45 file1.txt
-rw-r--r-- 1 rea fac_cs 0 2017-03-29 17:45 file2.txt
$ cd ..
$ man ls
$ exit
15
System commands
command description
man or info get help on a command
clear clears out the output from the console
exit exits and logs out of the shell
date output the system date
cal output a text calendar
uname print information about the current system
17
Unix file system
directory description
/ root directory that contains all others
(drives do not have letters in Unix)
/bin programs
/dev hardware devices
/etc system configuration files
/etc/passwd stores user info
/etc/shadow stores passwords
/home users' home directories
/media, drives and removable disks that have been
/mnt, ... "mounted" for use on this computer
/proc currently running processes (programs)
/tmp, /var temporary files
/usr user-installed programs
18
Directory commands
command description
ls list files in a directory
pwd print the current working directory
cd changes the working directory
mkdir create a new directory
rmdir delete a directory (must be empty)
19
Command-line arguments
• many accept arguments or parameters
example: cp (copy) accepts a source and destination file path
• for many commands that accept a file name argument, if you omit
the parameter, it will read from standard input (your keyboard)
21
File commands
command description
cp copy a file
mv move or rename a file
rm delete a file
touch create a new empty file, or
update its last-modified time stamp
• Exercise : Given several albums of .mp3 files all in one folder, move
them into separate folders by artist.
• Exercise : Modify a .java file to make it seem as though you
finished writing it on Dec 28 at 4:56am.
22
Exercise Solutions
• caution: the cp, rm, mv commands do not prompt for confirmation
easy to overwrite/delete a file; this setting can be overridden (how?)
• Use “-i” with the command, “interactive” to prompt before overwrite
• Exercise : Given several albums of .mp3 files all in one folder, move
them into separate folders by artist.
mkdir U2
mkdir PSY
mkdir JustinBieber
mv GangnamStyle.mp3 PSY/
mv Pride.mp3 U2/
• Exercise : Modify a .java file to make it seem as though you
finished writing it on Dec 28 at 4:56am.
touch –t "201812280456" Hello.java
23