8.1. Printing files
8.1.1. Command line printing
8.1.1.1. Getting the file to the printer
Printing from within an application is very easy, selecting the Print option from the menu.
From the command line, use the lp or lpr command.
lp file(s)
lpr file(s)
These commands can read from a pipe, so you can print the output of commands using
command | lp
There are many options available to tune the page layout, the number of copies, the printer that you want to print to if you have more than one available, paper size, one-side or double-sided printing if your printer supports this feature, margins and so on. Read the man pages for a complete overview.
8.1.1.2. Status of your print jobs
Once the file is accepted in the print queue, an identification number for the print job is assigned:
davy:~> lp /etc/profile
request id is blob-253 (1 file(s))
To view (query) the print queue, use the lpq or lpstat command. When entered without arguments, it displays the contents of the default print queue.
davy:~> lpq
blob is ready and printing
Rank Owner Job File(s) Total Size
active davy 253 profile 1024 bytes
davy:~> lpstat
blob-253 davy 1024 Tue 25 Jul 2006 10:20_01 AM CEST
8.1.1.3. Status of your printer
Which is the default printer on a system that has access to multiple printers?
lpstat -d
davy:~> lpstat -d
system default destination: blob
What is the status of my printer(s)?
lpstat -p
davy:~> lpstat -p
printer blob now printing blob-253. enabled since Jan 01 18:01
8.1.1.4. Removing jobs from the print queue
If you don’t like what you see from the status commands, use lprm or cancel to delete jobs.
davy:~> lprm 253
In the graphical environment, you may see a popup window telling you that the job has been canceled.
In larger environments, lpc may be used to control multiple printers. See the Info or man pages on each command.
There are many GUI print tools used as a front-end to lp, and most graphical applications have a print function that uses lp. See the built-in Help functions and program specific documentation for more.
Why are there two commands for every task related to printing?
- Printing on UNIX and alikes has a long history. There used to be two rather different approaches: the BSD-style printing and the SystemV-style printing. For compatibility, Linux with CUPS supports the commands from both styles. Also note that lp does not behave exactly like lpr, lpq has somewhat different options than lpstat and lprm is almost, but not quite, like cancel. Which one you use is not important, just pick the commands that you are comfortable with, or that you may know from previous experiences with UNIX-like systems.
8.1.2. Formatting
8.1.2.1. Tools and languages
If we want to get something sensible out of the printer, files should be formatted first. Apart from an abundance of formatting software, Linux comes with the basic UNIX formatting tools and languages.
Modern Linux systems support direct printing, without any formatting by the user, of a range of file types: text, PDF, PostScript and several image formats like PNG, JPEG, BMP and GIF.
For those file formats that do need formatting, Linux comes with a lot of formatting tools, such as the pdf2ps, fax2ps and a2ps commands, that convert other formats to PostScript. These commands can create files that can then be used on other systems that don’t have all the conversion tools installed.
Apart from these command line tools there are a lot of graphical word processing programs. Several complete office suites are available, many are free. These do the formatting automatically upon submission of a print job. Just to name a few: OpenOffice, KOffice, AbiWord, WordPerfect, etc.
The following are common languages in a printing context:
- groff: GNU version of the UNIX roff command. It is a front-end to the groff document formatting system. Normally it runs the troff command and a post-processor appropriate for the selected device. It allows generation of PostScript files.
- TeX and the macro package LaTeX: one of the most widely used markup languages on UNIX systems. Usually invoked as tex, it formats files and outputs a corresponding device-independent representation of the typeset document.
Technical works are still frequently written in LaTeX because of its support for mathematic formulas, although efforts are being made at W3C (the World Wide Web Consortium) to include this feature in other applications.
- SGML and XML: Free parsers are available for UNIX and Linux. XML is the next generation SGML, it forms the basis for DocBook XML, a document system (this book is written in XML, for instance).
Printing documentation
- The man pages contain pre-formatted troff data which has to be formatted before it can roll out of your printer. Printing is done using the
-t option to the man command: man -t command > man-command.ps Then print the PostScript file. If a default print destination is configured for your system/account, you can just issue the command man -t command to send the formatted page to the printer directly. For printing Info pages, refer to the Info pages on info (you will need the source code of the command).
8.1.2.2. Previewing formatted files
Anything that you can send to the printer can normally be sent to the screen as well. Depending on the file format, you can use one of these commands:
- PostScript files: with the gv (GhostView) command.
- TeX dvi files: with xdvi.
- PDF files: xpdf or Adobe’s viewer, acroread, which is also available for free.
- From within applications, such as Firefox or OpenOffice, you can usually select Print Preview from one of the menus.
Prev: Printers and printing
Home
Next: The server side
Copyright (c) by the authors.
This section of the wiki is licensed under the terms of the GNU Free Documentation License.
See the LBook-licensing page for details.
Linux® is a registered trademark of Linus Torvalds.
Welcome to LinuxBasics.org - The online community that helps people to get Linux installed and running.
During this tour, we will guide you through our website, which has many facets which wait to be explored
The biggest project we are running is our Linux course, based on the LBook.
The book is stored in wiki-format, which enables us to update and correct it as we go.
Discussion for the course is on our Forum
Our mailing-list is for any Linux-related question.
The questions and answers from the list are stored in the list's archives in order to help others with the same problems.
Every weekend, we meet to chat in IRC. These meetings are NOT mandatory, but are a nice chance to get to know each other better.
IRC is also a great tool to solve many problems, since it is very quick and easy to ask for more details if you need them.
The tutorials are one of the oldest sections on the LBo-website.
Here you find explanations on how to do specific tasks in Linux. Many of the tutorials were created after a certain problem
has been discussed (and usually solved :) on the mailing-list.
The tutorials are categorized in
In the links section, you find outbound links to other valuable resources.
One of our later additions to the site. We maintain a mirror of the Linux Documentation Project. This is our contribution to the "home of the HOWTOs"
Another later addition is the LBlog which focuses on how to do stuff on the Linux Desktop. It begins with the basics on installing Ubuntu.
Using the integrated site-search, you can search the tutorials, the LBook and all other wiki-pages
Simply type the search term into the box in the upper-right corner of our webpages
As a community, we depend on your feedback and collaboration. So, if you have something to share with others, please contact us. If you have a suggestion for a topic you would like to see covered here, please add it on the Wishlist.
There are many ways to contribute: You can answer questions on the mailing-list, you can write a complete tutorial or just a step-by-step documentation on how you completed a specific task using linux. Ask questions if the information on this site is not clear, tell us if we got something wrong, spell-check our writings, whatever.
We are looking forward to meeting you at LinuxBasics.org
Anita, Jisao, Sam and Stefan