1. Home
  2. Docs
  3. How do I
  4. Print from Linux?

Print from Linux?

CELS-managed Linux Desktops

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 foobar.ps on PrinterName — (where PRINTER is not set)

         lpr -PPrinterName 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 foobar.ps 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 PrinterName to see that Riley’s job is still in the queue.

         host.cels.anl.gov> lpq -PPrinterName
         PrinterName_local is ready and printing
         Rank   Owner      Job  Files                          Total Size
         active billybob   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 [email protected].

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

         host.cels.anl.gov> lpq -PPrinterName
         PrinterName_local is ready and printing
         Rank   Owner      Job  Files                          Total Size
         active billybob   200  /usr/tmp/ESa21345              1656725 bytes

you would type, and receive:

         host.cels.anl.gov> lprm -PPrinterName 200
         prtiners-240.cels.anl.gov: dfA200host.cels.anl.gov dequeued
         printers-240.cels.anl.gov: cfA200host.cels.anl.gov dequeued
         host.cels.anl.gov>

Self-managed Linux computers

You need to be running CUPS on your local machine.  Installing that and configuring it is outside the scope of this document, and presumes anyone running their own Linux laptop is capable of getting to this point.

Config with your web browser:

  • Connect to your local cups server at http://localhost:631
  • Select on the Administration tab at the top
  • Select Add Printer
  • Select Internet Printing Protocol (ipp)
  • Use the format ipp://printers-240.cels.anl.gov/printers/NAME where NAME is the name of the printer you want to add (e.g. pr-2d11-color)
  • Choose “Generic” for the make, then choose Generic PostScript Printer (en), since the server will be handling communication with the printer

Config with the OS setting printer app: (tested in Ubuntu)

  • Connect to your local cups server (select: server > connect > cups server: localhost:631)
  • Add new printer (select: server > new > printer)
  • In the New printer window (select: network printer > find network printer > host: printers-240.cels.anl.gov)
  • This will populate a list of all printers on the print server in a format such as ipp://printers-240.cels.anl.gov:631/printers/NAME
  • Find the printer you wish to add, highlight and select forward.

If you receive an “Unauthorized access” error when adding a printer in cups, modify the following fields in /etc/cups/cupsd.conf

Old:
<Location /admin>
Order allow,deny
</Location>

New:
<Location /admin>
AuthType Default
Require user @SYSTEM
Order allow,deny
</Location>

Followed by running “sudo service cups restart”

The list of common CELS printers in 240:

[table id=1 /]