UC San Diego SearchMenu

Printing Files in Unix

Information regarding printing files on a Unix system.

Sending files to printers

The command to send files to the printer is "lpr". If you have a Unix file named "myfile" type:

lpr myfile

Since you'll want to send your files to a printer close to you, you will need to specify the name of a particular printer i.e adding a "-P" with the printer's name. (Printer names are posted on or near the printer in question.)

For example: if you want to print to Laser35, in the Center Hall 315 Mac lab, you need to specify this to the system.

lpr -Plaser35 myfile


If you are using the GNOME environment on a Linux machine, you can just insert this command line into the "print command" field under the properties menu when you go to File -> Print.

If you know that you'll be doing a lot of printing during one login session, you can shorten what you need to type each time to print. You can change this default to anything you want by typing this command at the prompt:

 % setenv PRINTER printername

When you type this, change "printername" to the name of the printer in question.

After that, whenever you type "lpr myfile" during this login session, all printouts will be sent to the printer you specified.

If your print job does not appear at the printer in a reasonable amount of time, DO NOT send it repeatedly. For guidance, see the accompanying section "What to do if your job does not appear."

What to do if your job does not appear

If your print job does not appear on the printer in a reasonable amount of time, DO NOT send it repeatedly. Chances are, if your job didn't print the first time, it won't print again. Sending the job again will only produce the same result and may in fact aggravate the problem. Instead, follow these steps first:

  1. Wait a minute.
    It may take up to a minute or so for the pages to start coming out.
    If your header page has already come out, your document is on the way.
  2. Check the status indicators.
    If one of the lights is flashing or flickering, the laser printer is processing a job. Be patient.
    If a red light appears, the laser printer is jammed. Call Computer Operations (ext: 44097).
    AT&T line printers may indicate errors on their LCD readouts. If the readout displays anything other than "ON LINE," call Computer Operations.
    Other line printers may indicate an error with a large red light. If the light is on, report the problem to Operations.
  3. Check the printer queue.
    See the accompanying section "Checking printer queues" for information on how to do this. If the queue seems excessively long, call Computer Operations to verify that the queue is stuck.
    If the queue is stuck and you have to leave, remove your jobs from the queue. See the section "Removing jobs from printer queues."
  4. Make sure the appropriate destination was specified.
    Did you remember to specify the correct printer, either with the PRINTER environment variable or with the -P option to lpr? If not, you'll need to correct your error and resend the job.
  5. Check status of your real-money account.
    Laser printers require an active real-money account with ACMS. We have a tool to check balances for student accounts and for recharge accounts.


Printing to laser printers is disabled at the end of each day if the balance falls below $0.00. If you want to continue printing, you'll need to come by the ACMS Help Desk again to deposit more money into the account by check. You can also add money online.

Checking printer queues

If several jobs are sent to a printer, the first one received starts to print immediately and the remaining are placed in a queue. To see the current list of jobs that are waiting to print on any given printer (apm2337, in this example), use the following command:

% lpq -Papm2337

If you do not use the "-P" option, and you have set the PRINTER environment variable, then lpq will show you the queue for that printer.

Removing jobs from printer queues

To cancel the printing of a specific job that you have sent to a printer, you first need to check the queue of that printer and get the job number. Once you have that, use the lprm command to remove the job.
[The following example has running comments in square brackets

 % setenv PRINTER laser1         [only necessary once per session]
 % lpr jedimindtricks.txt        [print the file]
 % lpq                           [show the queue]

[Find your name in the "Owner" column (it's okenobi in this example) ]

 laser1 is ready and printing
 Rank   Owner      Job  Files                           Total Size
 1st    hsolo      432  blueprint.html                 13344 bytes
 2nd    okenobi    599  jedimindtricks.txt             6152 bytes

[remove the job using the number in the "Job" column]

 % lprm 599


If you do not have the PRINTER environment variable set properly, remember to use the -P option with the lpr, lpq, and lprm commands.

To remove all of your jobs on a specific printer queue, use a '-' as the "job number."

 % lprm -                [if PRINTER is set appropriately]
 % lprm -Plaser1 -       [to specify a specific printer]

Printing — Related Topics

Other Sources of Information

For further information about basic printing commands see:

man lpr
man lpq
man lprm
man lp