Documentation for the print
command
man print
only gives you information about a command called print
. Unfortunately, the command to print a file is not called print
.
Ksh and zsh have a built-in command print
. Like all built-ins, they are documented in the manual for the shell (man zshbuiltins
or the very long man zshall
for zsh). You can tell that a command is built-in with type
:
$ type printprint is a shell builtin
apropos print
would show a list of commands whose description contains the word “print”; what you're looking for is in there, but buried inside a lot of other commands where “print” is used in the sense of “display text in the terminal”.
On Debian and derived distributions including Ubuntu, there is a command called print
, which has a man page. It is part of the mime-support package, which also provides commands see
, edit
and compose
. This package uses /etc/mime.types
to determine the file's MIME type from the file name extension and /etc/mailcap
and ~/.mailcap
to determine which program to use.
On most Linux distributions, xdg-open
plays a similar role to Debian's edit
, but there is no analog for print
.
A primer on printing from the command line
Most unix installations these days use CUPS for printing. This system originated on Mac OS X but is now dominant on Linux and present on other unix variants as well. CUPS is easiest to configure through its web interface at http://localhost:631/
.
If the printer is already configured and you want to print, depending on your system, the command is either lp
or lpr
. The simplest form of the command is lp myfile.ps
or lpr myfile.pdf
; depending on which printing system your computer uses, these commands may support many options. Check the man page on your system for details. If you need to specify a printer name, it's lp -d printername myfile.ps
or lpr -Pprintername myfile.ps
.
The traditional file format for printing is PostScript. Nowadays, most printing systems support PDF out of the box as well, and possibly other formats. I don't think there's an easy way to find out what input formats are supported, so I recommend converting your file to PS or PDF before printing (you'll have more control over layout options that way anyway).
You can see what files are currently being printed with the command lpstat
or lpq
. This lets you know when your file has finished printing (or rather when it's been fully transmitted to the printer). This also tells gives you the job ID for your print job, which you can use to cancel the job with lprm
or cancel
. You can also see a list of available printers with lpstat -a
or lpq -a
.
If your system is using CUPS, another useful command is lpoptions
. The command lpoptions -l
lists printer options that you can use on the lp
or lpr
command lines; for example, with many duplex printers, lp -o Duplex=DuplexNoTumble
prints double-sided.