Notes: Unix Lab 13

  1. Unix Printing (lpr)
  2. lpq
  3. lprm
  4. Compressing files with tar, gzip and compress

  1. Unix Printing

    Printing in a unix environment is done with the lpr command. The lp command is used with BSD Unix and behaves a little bit different from lpr. lpr typically will submit a print command, referred to as a "job", to the printer daemon (lpd) on the local machine. lpd accepts the print job and passes it along to the requested printer. If there are multiple print requests lpd will sort them (usually by time) and send them to the printer in order. lpr has many options and can take several arguments which specify what file(s) to print:
     
    tuckerm@apollo:~> 
    tuckerm@apollo:~> lpr homework.txt
    tuckerm@apollo:~> 
    

    If no printer is specified, lpr will print to the printer named "lp" as defined in the file /etc/printcap. A specific printer can be indicated on the command line with the "-P" option:
     
    tuckerm@apollo:~> 
    tuckerm@apollo:~> lpr -P hp5si homework.txt
    tuckerm@apollo:~> 
    

    lpr can also pass a print job directly to the print queue on a remote host:
     
    tuckerm@apollo:~> 
    tuckerm@apollo:~> lpr -P hp5si@apollo homework.txt
    tuckerm@apollo:~> 
    

  2. lpq

    The lpq command is used to list all jobs that a Unix host has queued up to print. Occasionally a printer will become unavailable or a particular print job will block the queue. lpq allows a user to examine the contents of the queue. By default lpq will report on the queue for the default printer, lp:
     
    tuckerm@apollo:~> lpq
    Printer: hp5si@apollo 'gimp/pcl-5si;r=600x600;q=high;c=gray;p=letter;m=auto' (dest raw@hp5si.lsc.vsc.edu)
     Queue: no printable jobs in queue
     Server: no server active
     Status: job 'cloverl@annex05+507' saved at 15:47:22.197
     Rank   Owner/ID                  Class Job Files                 Size Time
    done   cloverl@annex05+507          A   507 /tmp/Acro000Vjzgr0 5659257 15:46:20
    JetDirect lpd: no entries
    tuckerm@apollo:~>
    

    lpq can used to view the queue for a specific user:
     
    tuckerm@apollo:~> lpq -P plotter
    Printer: plotter@apollo 'gimp/pcl-750;r=600x600;q=high;c=full;p=letter;m=auto' (dest raw@plotter.lsc.vsc.edu)
     Queue: 22 printable jobs
     Server: pid 28291 active
     Unspooler: pid 28292 active
     Status: sleeping 60 secs before retry, starting sleep at 16:08:58.405
     Rank   Owner/ID                  Class Job Files                 Size Time
    stalled(2909296sec) nobody@apollo+287 A 287 smbprn.000553.jZp7 1228950 00:01:15
    2      nobody@apollo+434            A   434 smbprn.000609.mftBuV 46464 19:42:55
    3      nobody@apollo+201            A   201 smbprn.000614.5bEXKw 48273 20:53:42
    4      nobody@apollo+987            A   987 smbprn.000647.eu0XoV 41500 17:42:00
    5      nobody@apollo+551            A   551 smbprn.000659.C2xkeQ 31592 18:09:14
    6      nobody@apollo+82             A    82 smbprn.000683.MlMID 456725 09:17:10
    7      nobody@apollo+652            A   652 smbprn.000765.nrWqB 431556 05:38:33
    8      nobody@apollo+178            A   178 smbprn.000798.vqUMay 37498 13:34:17
    9      nobody@apollo+349            A   349 smbprn.000799.zgLgLO 37498 13:38:13
    10     nobody@apollo+943            A   943 smbprn.000831.UYjo 1636265 14:12:17
    11     nobody@apollo+210            A   210 smbprn.000839.10eP 1615058 21:44:20
    12     nobody@apollo+523            A   523 smbprn.000842.UnjL 1615059 21:50:42
    13     nobody@apollo+439            A   439 smbprn.000849.GAUyp 262144 23:42:10
    14     nobody@apollo+944            A   944 smbprn.000851.UmLX2q 41822 02:08:42
    15     nobody@apollo+509            A   509 smbprn.000854.A90dBy 58615 02:51:44
    16     nobody@apollo+41             A    41 smbprn.000921.CzJRQq 30288 18:09:45
    17     nobody@apollo+922            A   922 smbprn.000923.XLnUoT 30100 19:39:39
    18     nobody@apollo+170            A   170 smbprn.000924.j9R1Ey 30348 19:43:29
    19     nobody@apollo+581            A   581 smbprn.000955.kTU0t 214107 00:42:51
    20     nobody@apollo+277            A   277 smbprn.000963.8jMfik 60974 16:54:01
    21     nobody@apollo+98             A    98 smbprn.000970.w1KeM 122011 01:18:32
    22     nobody@apollo+129            A   129 smbprn.000971.vHTf2 167814 01:20:01
    Printer 'raw@plotter.lsc.vsc.edu' - cannot open connection - No route to host
    tuckerm@apollo:~>
    

  3. lprm

    The lprm command is used to remove a print job from the print queue. Again, by default lprm will act on the printer named lp but others may be specified with the "-P" option. lprm requires the job id number (found in the output of lpq) to specify which print job to remove. Notice that a user cannot remove a print job for which they are not the owner:
     
    tuckerm@apollo:~> lprm -P plotter 82
    Printer plotter@apollo:
      checking perms 'nobody@apollo+82'
      no permissions 'nobody@apollo+82'
    Printer 'raw@plotter.lsc.vsc.edu' - cannot open connection - No route to host
    tuckerm@apollo:~>
    

    The root user may always remove a job:
     
    root@apollo:~# lprm -P plotter 82
    Printer plotter@apollo:
      checking perms 'nobody@apollo+82'
      dequeued 'nobody@apollo+82'
    Printer 'raw@plotter.lsc.vsc.edu' - cannot open connection - No route to host
    root@apollo:~#
    

  4. Compressing files with tar, gzip and compress

    Compression is used to reduce the size of a file for storeage or transmission on a network.