Blog

Printing from the Linux command line | Network World

There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options.

Printing from the Linux command line is easy. You use the lp command to request a print, and lpq to see what print jobs are in the queue, but things get a little more complicated when you want to print double-sided or use portrait mode. And there are lots of other things you might want to do — such as printing multiple copies of a document or canceling a print job. Let’s check out some options for getting your printouts to look just the way you want them to when you’re printing from the command line. Developer

Printing from the Linux command line | Network World

To view your printer settings from the command line, use the lpoptions command. The output should look something like this:

This output is likely to be a little more human-friendly if you turn its blanks into carriage returns. Notice how many settings are listed.

NOTE: In the output below, some lines have been reconnected to make this output more readable.

With the -v option, the lpinfo command will list drivers and related information.

The lpoptions command will show the settings of your default printer. Use the -p option to specify one of a number of available printers.

The lpstat -p command displays the status of a printer while lpstat -p -d also lists available printers.

To print a document on the default printer, just use the lp command followed by the name of the file you want to print. If the filename includes blanks (rare on Linux systems), either put the name in quotes or start entering the file name and press the tab key to invoke file completion (as shown in the second example below).

The lpq command displays the print queue.

With the -n option, the lp command allows you to specify the number of copies of a printout you  want.

To cancel a print job, you can use the cancel or lprm command. If you don't act quickly, you might see this:

To print in two-sided mode, you can issue your lp command with a sides option that says both to print on both sides of the paper and which edge to turn the paper on. This setting represents the normal way that you would expect two-sided portrait documents to look.

If you want all of your documents to print in two-side mode, you can change your lp settings by using the lpoptions command to change the setting for sides.

To revert to single-sided printing, you would use a command like this one:

To print in landscape mode, you would use the landscape option with the lp command.

The print system used on Linux systems is the standards-based, open source printing system called CUPS, originally standing for Common Unix Printing System. It allows a computer to act as a print server.

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

Printing from the Linux command line | Network World

HP-Charge Unit/Corona The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.