introduction to unix – cs 21 lecture 2. lecture overview starting out in unix getting help when...
TRANSCRIPT
![Page 1: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/1.jpg)
Introduction to Unix – CS 21
Lecture 2
![Page 2: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/2.jpg)
Lecture Overview Starting out in Unix
Getting help when needed Looking around a little
Environment and Environment Variables
The Unix file structure Organization Navigation
![Page 3: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/3.jpg)
Logging In (And Logging Out) Your Unix experience begins with a
login prompt Login name and password
Always be sure to log out Why?
Malicious people shouldn’t have access to your account
Locking the screen…is it safe? Well, maybe, maybe not
![Page 4: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/4.jpg)
Good Password Versus Bad Password What makes a bad password?
Any word in a dictionary Any word from a sci-fi movie/show 30 sec – 8 minutes to break
What makes a good password? Easily interpreted and remembered by user Looks like random gibberish to others
passwd normally changes your password
![Page 5: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/5.jpg)
I’m In, Now What? No “tour of Unix” like Windows has You’re pretty much on your own Unix assumes you know what you
are doing You are given just enough leverage
to either do everything well or really mess everything up
![Page 6: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/6.jpg)
Where To Get Help man
The most important command in all of Unix RTM
info More complete descriptions of certain
packages help
Shell specific commands apropos whatis
(RTFM)
![Page 7: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/7.jpg)
Man Page Sections And What They Mean 1 – User commands 2 – System Calls 3 – C library routines 4 – Administrative files 5 – Miscellaneous 6 – Games 7 – I/O and special files 8 – System administration commands
![Page 8: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/8.jpg)
More on man Other sections exist (such as the perl
reference manual and the tcl reference manual)
-a will show all the man pages that match First is shown by default
How would you find out more about man? man man
![Page 9: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/9.jpg)
Example
![Page 10: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/10.jpg)
How Am I Supposed To Read This? Name:
The name of the program and a brief description
Synopsis: How to run this command
Description: Listing of all flags and what they do
See also: Relevant related commands
![Page 11: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/11.jpg)
What Do You Do If There Isn’t A Man Page? Option 1: run the program and hope
it doesn’t destroy anything Option 1b: run the program with random
flags and see what exactly it destroys Option 2: do a little snooping
Check for man pages or documentation on the web
See if there are any environment variables that it might use
![Page 12: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/12.jpg)
Who is logged on and what are they doing? users
Shows a list of all currently logged on users who (and whoami)
Shows a list of all currently logged on users and where they are logged on from
w Shows a list of all currently logged on users
and what they are running finger
Tells a little more information about users
![Page 13: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/13.jpg)
Privacy issue? You can tell when someone else is
logged on and exactly what they are doing
Everyone else can see what you are doing
Is this acceptable?
![Page 14: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/14.jpg)
One User To Rule Them All The superuser – root
Root has the permission to do anything Including wiping the entire system clean
The system will allow root to do just about anything
Comparable to “Administrator” in Windows Of course, any user in Windows XP can be
designated an Administrator and install software
![Page 15: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/15.jpg)
No, You Can’t Get Root For obvious reasons, you will not
be given root access Don’t feel bad though, very few
people at school have root You can always install your own
machine at home to play around with Knoppix
![Page 16: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/16.jpg)
Environment And Environment Variables A set of preset variables that all
programs run from that shell can see
In order to see them, run the command: printenv
Set environment variables with the command: export VAR=VALUE
Clear environment variables with: unset VAR
![Page 17: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/17.jpg)
Example
![Page 18: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/18.jpg)
Stupid Analogy Of The Day
Each contain useful information Every program can check them out and
read them If someone changes them, the next person
to check them out will see those changes
Environment Variables =
![Page 19: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/19.jpg)
Exporting Or Not If you don’t export the variable, it
is a local variable and not accessible to everyone
Get access to a local variable by using the dollar sign ($VAR)
![Page 20: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/20.jpg)
A Very Important Environment Variable PATH
Tells Unix where to look in order to find programs to run
Very important hint: When typing a command, you should be able to
hit the tab key in order to complete it Called tab completion, this is a most invaluable tool The system searches your PATH for any program it
can run that matches what you have typed so far
![Page 21: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/21.jpg)
Files, Files Everywhere Unix treats almost everything as a
file Standard text files and binaries Directories Links Even devices!
Your terminal is a file, your keyboard is a file, your hard drive is a file, everything is a file!
![Page 22: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/22.jpg)
What Was That? To repeat, Everything in Unix is a
file! Why?
This goes back to the design of Unix trying to keep everything simple
Treating everything the same allows for a simple interface to interact with everything in the same way
![Page 23: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/23.jpg)
Unix Directory Structure Everything is a file, and the directory
structure is like a filing cabinet
![Page 24: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/24.jpg)
Inverted Tree Structure/
/usr /bin /home
/var/lib
/home/csmajs
/home/csgrads
/home/csmajs/undergrads
/home/csgrads/graduates
![Page 25: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/25.jpg)
What Goes Where? /
Root of the entire system Comparable in Windows to C:\
Windows, however, has several roots depending on what partition and device you are looking at
/bin Commonly used binaries (programs)
![Page 26: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/26.jpg)
And… /sbin
More programs to run Statically linked Still should run if you tinker around and
mess things up
/usr User related commands as well as a
whole bunch of random stuff
![Page 27: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/27.jpg)
And… /lib
Libraries go in here /dev
All devices are located in here /home
Traditionally, this is where user accounts are stored
/etc Startup files and configuration files for
daemons and other programs
![Page 28: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/28.jpg)
And… /var
Various files go in here Traditional location of mailboxes
/var/spool/mail
/proc Special files that contain information
about the system or info from running programs
![Page 29: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/29.jpg)
Navigating The Directory Structure You are always located at one location
in the tree ls
Provides a listing of the current directory All files and directories are shown
cd Change directory “cd /” Moves your current directory to / cd without any arguments moves you to
your home directory
![Page 30: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/30.jpg)
Creating And Removing Directories mkdir
Makes a directory “mkdir myDir”
rmdir Removes an empty directory “rmdir myDir”
![Page 31: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/31.jpg)
A Couple Of Notes Unix is case-sensitive
myDir is different from MyDir and mydir Not all files are shown with ls
“ls –a” will show all files Hidden files in Unix always start with a .
Example: .hidden .plan
![Page 32: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/32.jpg)
Command Line Options Almost all Unix commands have
options that change what they do Read the man pages for a listing
They have the form: -a Depending on the command, they
may be lumped together -a –l is the same as -al
![Page 33: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/33.jpg)
How Different?
![Page 34: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/34.jpg)
Special Directories .
This stands for the current directory ..
This stands for the directory directly above the current directory
~ Your home directory
These directories can be “stacked” “../..” stands for two directories directly
above the current directory
![Page 35: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/35.jpg)
Relative Versus Absolute Pathnames Unix supports two different styles for
directories Absolute pathnames
Always start from / and contain the entire route
“/home/csgrads/villarre” Relative pathnames
Assumed to be relative to current directory Doesn’t start with a / “classes/cs21”
![Page 36: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/36.jpg)
Advanced Navigation Through The Directory Structure pushd
“Push” a directory onto a stack popd
“Pop” a directory from a stack A Stack is what’s known as a LIFO
structure Last in, first out
![Page 37: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/37.jpg)
How Does A Stack Work?
e
d
c
b
a
![Page 38: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/38.jpg)
How Does A Stack Work?
e
d
c
b
a
d
![Page 39: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/39.jpg)
How Does pushd and popd Work?
/var/spool/
/home/csmajs
/bin
/usr
/home
pushd /var/spoolpushd /home
popd
popd
Current Directory:
/home/csmajs/var/spool/home/var/spool/home/csmajs
![Page 40: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/40.jpg)
Today In Lab Put all of the material from today
into practice Lab will be posted later today at:
www.cs.ucr.edu/~villarre/cs21/
![Page 41: Introduction to Unix – CS 21 Lecture 2. Lecture Overview Starting out in Unix Getting help when needed Looking around a little Environment and Environment](https://reader031.vdocuments.net/reader031/viewer/2022012922/56649ead5503460f94bb3f67/html5/thumbnails/41.jpg)
Reading Assignment Read chapters 2-4 I will assign a homework beginning
of next week First quiz will be a week from next
Tuesday