Navigating Unix

Document Sample
scope of work template
							Navigating Unix

          UCR Technical Seminar Series
                               Fall ’03
               Dan Berger dberger@cs
Outline
  Unix History/Philosophy
  File System Basics
  Utilities You Shouldn’t Leave ~/ Without
     Web, Mail, Office, Windows
   Printing
   Looking for Help
   Asking for Help
   Learning More
Slides online at http://www.cs.ucr.edu/~dberger
A Brief History of Time^wUnix
 Born in the late 60’s at AT&T/Bell Labs out of the
 MULTICS project. Ran on a PDP-11.
   Thompson, Ritchie, Kernighan, among others.
 In the 70’s AT&T was prohibited from selling
 Unix, so they gave it to universities.
 The contributions from some of those
 universities (such as Berkeley), and later from
 MIT, evolved Unix into the basic form it still holds
 today.
Unix Philosophy
 Small tools, each of which does one job well.
 Build pipelines of these tools to accomplish loftier goals.
 Users interact with the system through the ―shell‖ – a
 command-line interface.
 It’s all about user choice – why have one when you can
 have three?

 ―Here’s the rope, there’s the tree – help yourself.‖
File System Basics: /
 There’s no ―C:\‖, or ―Macintosh HD‖ – the file
 system is a tree, rooted at ―/‖
 Additional volumes can be ―mounted‖ at (fairly)
 arbitrary spots in the tree.
 Some key portions of the tree:
   /bin                  /dev
   /etc                  /home
   /lib                  /mnt
   /proc                 /tmp
   /usr                  /var
. and ..
 Every directory has two special entries: ―.‖ and
 ―..‖
 ―.‖ is the current directory
 ―..‖ is one level up toward the root (/)
 Confusing them can be unpleasant…



 Trick Question: what directory does ―/..‖ refer to?
Home Directories
 Unix is inherently multi-user – and in a multi-user
 system, users can’t scribble their files around at
 random.
 Each user on a Unix system has a ―home
 directory‖ – it’s contents, organization (or lack
 thereof) are completely up to you.
 When you log in, you are placed in your home
 directory (abbreviated ~/).
Manipulating Files from the Shell
             Task               Command
 Change Directory          cd target
 Copy                      cp src dst
 Display disk Usage        du target
 List Files                ls (ls –a, ls –l)
 Move                      mv src dst
 Make Directory            mkdir target
 Print Working Directory   pwd
 Remove                    rm target
 Remove Directory          rmdir target
File Permissions
 Recall: unix is multi-user – the file system keeps
 track of who’s allowed to read, write, and
 execute a given file.
 The world is divided into three: the user that
 owns the file, other users in the group that owns
 the file, and everyone else (other).
 Changing the mode of the file is done with the
 chmod command.
   Permissions are octal bit vectors – one byte for each
   of the three groups and a prefacing special byte.
Permissions (Cont.)
 Directories have permissions too:
   read: read the contents of the directory (not
   necessarily the contents of the files themselves)
   write: remove and rename (but not create) files in the
   directory (not necessarily write to existing files)
   execute: access the directory (cd into it)
 Newly created files (and directories) have their
 default permissions set to (7777 && umask).
   umask will report your umask.
Utilities Not to Leave ~/ Without
 ssh – secure shell – execute commands (or get
 an interactive shell) on a remote machine over
 an encrypted network connection.
   It’s so cool and versatile, it’s getting it’s own seminar!
 scp – secure copy – copy files between two
 hosts over an encrypted network connection.
 (mostly replaces FTP)
 rsync – keep directory trees on different
 machines synchronized.
Browsing the Web
 Mozilla – it’s cross platform and standard and
 buzz-word compliant.
 Galeon – part of the GNOME desktop – it’s built
 on (and embeds) mozilla.
Reading Mail
 Remember ―it’s all about choice?‖ There are
 many possible mail readers – the department
 recommends (i.e. the systems group supports):
   Evolution – something of a MS Outlook ―work-alike,‖
   but without the propensity for worms and other
   unpleasantness.
 Other clients include mozilla (gui), mutt (curses).
 imaps://imap.cs.ucr.edu
 smtp://mail.cs.ucr.edu
Handling Windows Documents
 Office documents (Word, Excel, Powerpoint) can
 be opened using Open Office (ooffice).

 Try gnumeric on your Excel documents, and
 abiword on your Word documents.
Printing from Unix
 PostScript is the lingua franca of Unix printing.
 That means if what you want to print isn’t
 PostScript, something has to do the conversion.
   It also means that if your printer doesn’t understand
   PostScript, something has to do that conversion as
   well.
 Fortunately, all the department printers
 understand PostScript
enscript
 If you have an ASCII file (e.g. source code) that
 you want printed – enscript is your friend.
 It will turn ASCII into PostScript – and even print
 two pages to a page.
 Add the following to your .bashrc:
   export ENSCRIPT=―—landscape –columns=2 –
   borders –line-numbers –pass-through‖
 enscript –P printername source.cc
Printing PostScript Files
 If you already have a PostScript file, your life is easier:
    lp –P printername file [file…]


 Note that PDF’s are not PostScript – don’t send them to
 lp unless you want to waste a ream of paper.
 Also note that printing a postscript file through enscript
 (or a2ps) will likely result in similar waste.
Checking Your Print Job
 lpq –P printername - shows the print queue for
 the given printer.
   If your job doesn’t appear on the printer – check lpq
   before you submit it again – make sure it’s not just
   stuck behind another job.
 lprm –P printername – removes your job from
 the specified queue.
Running Windows
 If you absolutely must run windows – just type
 ―windows.‖
   It launches a Windows Terminal Server client.
 You won’t remember this when you need to –
 but press Control-Alt-Enter to toggle full screen
 mode.
Finding Help (man, info, google)
 man man
 man subject
 man –k subject
 info subject
 info –apropos=subject
 http://www.google.com
   google://your+question+here
Asking for Help
 If you’ve looked in all the places mentioned in
 the previous slide, and you still can’t figure it out
 – there are some simple rules that will improve
 your chances of getting a good answer from a
 human:
 http://www.catb.org/~esr/faqs/smart-questions.html
Who To Ask?
 Lab mates, friends, strangers, and finally:
 systems@cs.ucr.edu
Learning More
 Teach Yourself Unix in 24 Hours by Dave Taylor
 Unix Fundamentals course (undergrad, upper
 division).
   If you’re interested, drop me an email and I’ll try to
   get the course offered once we have sufficient
   interest.
 Install Linux on your home machine (or
 notebook)
   Linux Administration: A Beginners Guide by Steve
   Shah (a UCR alum).
Shell ―Scriptlett’s‖
 shell is also a powerful system scripting
 language – supporting conditionals, loops,
 variables, etc.
for file in *; do         if [ -f somefile ]; then
   echo $file;              echo “it exists”;
done                      else
x=0                         echo “doesn’t exist”;
while [ $x –lt 10 ]; do   fi
   let x=x+1
   echo $x
done

						
Related docs
Other docs by fso56144