Introduction to Unix CS 21 - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Introduction to Unix CS 21

Description:

Put before your name, and before anything else ... These jobs hang around until the printers start working again, and then everything gets printed ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 29
Provided by: vill7
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Unix CS 21


1
Introduction to Unix CS 21
  • Lecture 14

2
Lecture Overview
  • Lab Questions
  • Backup schemes
  • Using tar to archive
  • Printing in Unix
  • lpr
  • lpq
  • Lprm
  • Quiz 2

3
Bash Shell Scripting Clarifications
  • /bin/bash
  • Must be the absolute first line in your script,
    otherwise it is meaningless
  • Put before your name, and before anything else
  • will start a comment, so put in front of your
    name
  • Always run your scripts to verify what they are
    doing before you turn them in

4
Take Home Assignment Clarifications
  • This is longer than all other programs so far, so
    if you havent started yet, start ASAP
  • Due at the beginning of lab on Thursday (600 pm)
  • Hints
  • Awk can be treated like just another bash
    program, so you can make calls and awk programs
    inside your bash shell script
  • Indent for readibility (Comment for
    understandability)

5
Once A File Is Gone, Its Gone
  • The only way to prevent data loss is to keep a
    recent copy somewhere safe
  • Of course, the entire hard drive could fail, so
    to be safer you need it in multiple locations
  • Other hard drives
  • Backup tapes

6
Our System - RAID
  • Redundant array of independent disks
  • Every hour a process checks and stores away any
    difference in your directories and files
  • Places these files in the .snapshot direcotry
  • Located on one or more other drives

7
Tape Archive - tar
  • Designed to store files onto a tape device
  • Now used for for storing and collecting files
    anywhere
  • Creates and maintains archives
  • Commonly seen as XXXX.tar files
  • Usage tar FLAGS FILES

8
Common Flags
  • -c
  • Create an archive
  • -f
  • Specify file
  • -x
  • Extract an archive
  • -t
  • List an archive

9
Creating A tar Archive
  • tar cf backup.tar FILES
  • tar c FILES gt backup.tar
  • As always, if you use file redirection be careful
  • Easy to overwrite

10
Example
11
Listing A tar Archive
  • tar tf backup.tar
  • tar t lt backup.tar
  • Will simply print out a list of all files located
    in that tar archive without changing them

12
Example
13
Extracting A tar Archive
  • tar x lt backup.tar
  • tar xf backup.tar
  • Will create all of the files in their respective
    directories
  • Will overwrite any files that are there already,
    so be carefule

14
Example
15
Automatically Compressing A tar Archive
  • -Z
  • Runs zip automatically on all files
  • -z
  • Runs gzip automatically on all files
  • Example
  • tar czf compressed.tar.gz .txt

16
The Most Common Usage
  • Tarfile.tar.gz
  • Referred to as a tarball
  • Almost all Unix programs and packages are
    available in this form
  • To extract them
  • tar xzvf tarball.tar.gz

17
Example
18
Basic Printing In Unix
  • The printers expect to be given a .ps file
  • Postscript
  • Other formats may or may not work or may come out
    ugly
  • Pdf (Adobe Acrobat format)
  • Ascii (Straight text)

19
lpr
  • Directly feed a printer a ps file to print
  • Usage lpr FLAGS toPrint.ps
  • Most common flag
  • -Pname
  • Specifies the name of the printer to send it to
  • Default is located in /etc/cups/lpoptions

20
lpq
  • Prints out a list of all jobs waiting to be
    printed from a specific printer
  • Each job has an associated job ID
  • Usage lpq FLAGS
  • Most common usages
  • lpq
  • lpq -Pname

21
Poor Example
22
lprm
  • Used to remove jobs from the queue
  • Usage lprm FLAGS jobID
  • Example
  • lprm Pname 23

23
Always Remove Your Print Jobs That Dont Print!
  • Sometimes, the printers dont work and people
    send jobs to the printers without knowing it
  • These jobs hang around until the printers start
    working again, and then everything gets printed
  • Your work could print out when youre not there
    and someone else could take it

24
a2ps
  • Convert ASCII files into the .ps format
  • Usage a2ps FLAGS asciiFile
  • Examples
  • a2ps o printMe.ps asciiFile
  • a2ps Pname asciiFile

25
pdf2ps
  • Converts Pdf format files into .ps files
  • Usage pdf2ps input.pdf output.ps

26
Viewing ps, pdf, And Other Files
  • gs
  • Ghostscript
  • A basic ps and pdf viewer
  • gv
  • Ghostview
  • A more user friendly ps and pdf viewer
  • xpdf
  • A pdf viewer

27
Next Time
  • Perl Programming Basics
  • Syntax
  • When would you use perl?

28
Quiz 2
  • Good Luck
Write a Comment
User Comments (0)
About PowerShow.com