From CELS IT Wiki
< Printers(Redirected from Printing On Linux)
Jump to: navigation, search

This document is aimed at MCS Green Linux Desktop users. Linux desktops use the CUPS client to talk to our print server. Most lpr command-line commands are provided by CUPS. See the man pages of any commands that don't work as expected.

How do I set the default printer on a linux box?

If you set the environmental printer variable, you will not need to specify which printer you wish your output to go to each time. This can be set (or reset) in a particular shell; in which case the definition lasts the lifetime of the shell (or until you reset it). The printer variable can also be set in your shell's initialization file (for example, the .tcshrc if you use tcsh). In either location, type

         setenv PRINTER printer_name

If you're not sure what your current default printer is, you can check by giving the command:

         printenv PRINTER

How do I print a file from linux?

If you are using a Ubuntu Linux desktop, you should able to print directly from most applications. Debian Sarge desktops are hit or miss. In any case, printing from the command will work.

Plain text files (ones you can read) can be printed using enscript. Enscript converts these files to postscript format and then sends them to the specified printer. For example, where PRINTER is set,

         enscript foobar

will print the file. See man enscript for a complete explanation.

Files already in postscript format (generally end in ".ps" and are "gibberish" if you read them) can be printed using lpr. (A file is determined to be a postscript file if the first two characters are "%!".) For example, to print file on pr-d255 -- (where PRINTER is not set)

         lpr -Ppr-d255 foobar

Dvi files (end in ".dvi" and are also "not readable") must be turned into postscript before printing. dvips converts dvi files into postscript. (See man dvips for more information.) Therefore, to print the file "foobar.dvi", do

         dvips foobar.dvi

which will generate a file. (Then see info on printing postscript files.)

I printed my file in linux, but it hasn't come out of the printer yet. What's up?

First, check to see if the file is still in the print queue (hasn't been printed yet because people are ahead of you). For example, to check pr-d255 to see that Riley's job is still in the queue.
> lpq -Ppr-d255
         pr-d255_local is ready and printing
         Rank   Owner      Job  Files                          Total Size
         active riley       200  /usr/tmp/ESa21345              1656725 bytes

If the file has been printed, your job may be sitting on the table or the shelves around the printer. Mainly, just look around. If you still can't find it, try again. If you think there are problems with the printer, email

Please recycle any unwanted printouts. The recycling bin is right inside the door to the printer room.

Oops. I sent a file to the printer, from linux, I didn't mean to

Use lprm to remove jobs from the printer queue, using the job id given under an lpq. So, for this job
> lpq -Ppr-d255
         pr-d255_local is ready and printing
         Rank   Owner      Job  Files                          Total Size
         active riley       200  /usr/tmp/ESa21345              1656725 bytes

you would type, and receive:
> lprm -Ppr-d255 200 dequeued dequeued>

Printing on a Linux Laptop

Depending on how old your OS and Kernel are, one of the following two ways should work for you. In general, these have been tested to work on Ubuntu, CentOS and Linux Mint. However, CLS Systems does not officially support Linux laptops and we can't guarantee it's stability.

Assuming cups is already installed and that you are on an Authenticated Argonne Network...

Ubuntu <=12.04 & Older Kernels

If you wish to print from your Linux laptop with CUPS, the easiest way would be to poll our server for printers. You can do this with the following commands.

 cupsctl Browsing=On 

Ubuntu >=13.04 and Newer Kernels

The CUPS BrowsePoll feature was removed in Ubuntu 13.04 as well as other flavors of Linux, but was eventually added back elsewhere in CUPS 1.6, although with modified configs. Connecting to our print server requires a slightly different approach by doing the following. Follow this exact order:

 cupsctl Browsing=On
 echo "ServerName" | sudo tee /etc/cups/client.conf

Finally, restart CUPS:

 sudo /etc/init.d/cups restart

You may need to wait a bit for the printers to show up, otherwise a reboot should help.