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:~> |
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:~> |
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:~# |
compress is the older of the compression utilities.
It typically will append a ".Z" to the file name of a
compressed file although this is not required.
uncompress is used to decompress a compressed file.
|
||||
>> >> ls -l zipback.sh -rwxr--r-- 1 mark users 1120 Feb 10 07:51 zipback.sh >> compress zipback.sh >> ls -l zipback.sh.Z -rwxr--r-- 1 mark users 675 Feb 10 07:51 zipback.sh.Z >> uncompress zipback.sh.Z >> ls -l zipback.sh -rwxr--r-- 1 mark users 1120 Feb 10 07:51 zipback.sh >> |
gzip is somewhat newer than compress and provides significantly
better compression. gzip typicall appends the ".gz"
extension to the file name during compression. gunzip or gzip -d
are used to decompress a gzipped file and will remove the
".gz" filename extension.
|
||||
>> >> ls -l zipback.sh -rwxr--r-- 1 mark users 1120 Feb 10 07:51 zipback.sh >> gzip zipback.sh >> ls -l zipback.sh.gz -rwxr--r-- 1 mark users 479 Feb 10 07:51 zipback.sh.gz >> gunzip zipback.sh.gz >> ls -l zipback.sh -rwxr--r-- 1 mark users 1120 Feb 10 07:51 zipback.sh >> |
bzip2 is a less commonly used compression utility but
is still seen
occasionally. It provides much higher levels of compress on larger
data files but is slower in accomplishing its compression.
bzip2
will append the filename extension ".bz2" to the filename
during compression. bunzip2 or bzip2 -d
are used to decompress a
bzip2 compressed file. The ".bz2" filename
extension is removed during decompression.
tar:tar (tape archive) is historically used to archive
files and directories to a tape device. Currently, it is more
commonly used to archive files and directories to a file file on the
file system. This archive, referred to as a "tarfile" can
then be expanded at a different location on the file system or on a
different host using the tar command with a different set of options.
options:
-c create an archive
-v verbose output
-f file to create or extract
-x extract contents of an archive
-z gzip archive during creation or decompress during exctraction
To create a tar archive:
|
||||
>>tar -cvf tarfile.tar /paths/to/archive /files/to/store.txt |
Using wildcards:
|
||||
>>tar -cvf tarfile.tar *.dat |
Extracting an archive:
|
||||
>>tar -xvf tarfile.tar |
Creating a tar archive with compression:
To create a tar archive:
|
||||
>>tar -czvf tarfile.tar.gz /paths/to/archive /files/to/store.txt |
Extracting a gzip compressed archive:
|
||||
>>tar -xzvf tarfile.tar.gz |
Listing the contents of an archive:
|
||||
>>tar -tvf tarfile.tar |