Introduction to Unix CS 21 Lecture 14 Lecture
- Slides: 28
Introduction to Unix – CS 21 Lecture 14
Lecture Overview n n Lab Questions Backup schemes n n Printing in Unix n n Using tar to archive lpr lpq Lprm Quiz 2
Bash Shell Scripting Clarifications n #/bin/bash n n 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
Take Home Assignment Clarifications n n n This is longer than all other programs so far, so if you haven’t started yet, start ASAP Due at the beginning of lab on Thursday (6: 00 pm) Hints: n n 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)
Once A File Is Gone, It’s Gone n n 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 n n Other hard drives Backup tapes
Our System - RAID n n n 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 n Located on one or more other drives
Tape Archive - tar n Designed to store files onto a tape device n n Now used for storing and collecting files anywhere Creates and maintains archives Commonly seen as XXXX. tar files Usage: tar [FLAGS] [FILES]
Common Flags n -c n n -f n n Specify file -x n n Create an archive Extract an archive -t n List an archive
Creating A tar Archive n n n tar –cf backup. tar FILES tar –c FILES > backup. tar As always, if you use file redirection be careful n Easy to overwrite
Example
Listing A tar Archive n n n tar –tf backup. tar –t < backup. tar Will simply print out a list of all files located in that tar archive without changing them
Example
Extracting A tar Archive n n tar –x < backup. 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
Example
Automatically Compressing A tar Archive n -Z n n -z n n Runs zip automatically on all files Runs gzip automatically on all files Example: n tar –czf compressed. tar. gz *. txt
The Most Common Usage n n Tarfile. tar. gz Referred to as a “tarball” Almost all Unix programs and packages are available in this form To extract them: n tar –xzvf tarball. tar. gz
Example
Basic Printing In Unix n The printers expect to be given a. ps file n n Postscript Other formats may or may not work or may come out ugly n n Pdf (Adobe Acrobat format) Ascii (Straight text)
lpr n n n Directly feed a printer a ps file to print Usage: lpr [FLAGS] to. Print. ps Most common flag: n n n -Pname Specifies the name of the printer to send it to Default is located in /etc/cups/lpoptions
lpq n n 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: n n lpq -Pname
Poor Example
lprm n n n Used to remove jobs from the queue Usage: lprm [FLAGS] job. ID Example: n lprm –Pname 23
Always Remove Your Print Jobs That Don’t Print! n n n Sometimes, the printers don’t 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 you’re not there and someone else could take it
a 2 ps n n n Convert ASCII files into the. ps format Usage: a 2 ps [FLAGS] ascii. File Examples: n n a 2 ps –o print. Me. ps ascii. File a 2 ps –Pname ascii. File
pdf 2 ps n n Converts Pdf format files into. ps files Usage: pdf 2 ps input. pdf output. ps
Viewing ps, pdf, And Other Files n gs n n n gv n n n Ghostscript A basic ps and pdf viewer Ghostview A more user friendly ps and pdf viewer xpdf n A pdf viewer
Next Time n Perl Programming Basics n n Syntax When would you use perl?
Quiz 2 n Good Luck
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Introduction to biochemistry lecture notes
- Introduction to psychology lecture
- Introduction to algorithms lecture notes
- Is unix and linux same
- Examples of os
- Unix was originally developed in
- Why unix was developed
- History of unix
- Objetivo de unix
- Shared memory in unix
- Unix device drivers
- Namei algorithm in unix
- Iget algorithm in unix
- A.out vs elf
- Internal command in unix
- Block diagram of unix operating system
- Unix architecture
- Explain shell interpretive cycle in unix
- Posix api
- Unix linux difference
- Unix 101
- Unix cpp sys wipro
- Unix adalah
- Unix time sharing system
- Hszx
- Unix 1969
- Directory file in unix
- Cgi-bin/printenv.pl exploit