Printing Files in Unix


Information regarding printing files on a Unix system.

Steps to Take

Sending files to printers

  1. 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 -P laser35 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.


  2. 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:

    export PRINTER = "printername"

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


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


  4. 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 doesn't appear

  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 the ITS Service Desk at (858) 246 - 4357. AT&T line printers may indicate errors on their LCD readouts. If the readout displays anything other than "ON LINE," call the Service Desk. Other line printers may indicate an error with a large red light. If the light is on, report the problem to the Service Desk.

  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 the Service Desk 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 ITS. 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 add money online

Sending files to printers

  1. 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 -P apm2337
  2. 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 printing queues

  1. 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

     # export 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

  1. Other Sources of Information

    For further information about basic printing commands see:

    man lpr
    man lpq
    man lprm
    man lp


If you still have questions or need additional assistance, please submit a ticket or call the ITS Service Desk at (858) 246-4357