Changing the default printer on Linux and Firefox

by on August 21, 2006

in How to,Linux/Ubuntu

If your Linux system uses CUPS, you can change the default printer for Firefox or Mozilla with this command:

lpoptions -d printer-name

The ‘d’ option sets the default printer.

If you want to set a default printer for command-line programs, I’d set a variable in your shell start-up configuration file. If your shell is bash (which is the most common), you’d use the syntax in your ~/.bashrc file:

export PRINTER=printer-name

If you use csh or tcsh, put this in your ~/.cshrc or ~/.tcshrc files:

setenv PRINTER printer-name

If you’re a csh person, you might ask the difference between set PRINTER=printer-name and setenv PRINTER printer-name. The difference is that set makes a regular variable, and setenv creates an environmental variable. Regular variables are available only within csh. With an environmental variable, any program that you run from csh can also see the environmental variable.

{ 28 comments… read them below or add one }

Aaron Pratt August 21, 2006 at 3:33 pm

And that is why people still use Windows! :)

Welcome back Matt.

Reply

Scott S. August 21, 2006 at 4:28 pm

That takes me back to the DOS days…. cd../ dir/p

Reply

Hawaii SEO August 21, 2006 at 5:06 pm

That’s way too easy. Where is the challenge in that? There must be a more complicated way to get something to print. :)

Reply

David Maple August 21, 2006 at 6:02 pm

Nice Matt! Coming over to the light side of the force.

Knowing the command line is a pretty useful skillset in my opinion — one that I would definitely hire based on. It strikes me as funny that guys who hand code HTML, ASP, and PHP would scoff at the notion of CLI commands. Oh well — different degrees of geekdom I guess.

To the windoze enthusiasts: In Ubuntu you can just go System->Administration->Printing to set up a printer in GUI just like Bill will let you do. These printers are also available in Firefox by default.

Reply

ark August 21, 2006 at 7:35 pm

that works, unless you want the default printer to be generic postscript and then firefox doesn’t seem to be able to remember that at all.

Reply

Andrew August 21, 2006 at 8:19 pm

Actually, setting the $PRINTER environment variable works for Firefox too, as long as you set it somewhere before Firefox is started (.xinitrc or .xsession are two places that come to mind). That should be the preferred method, because lpoptions is CUPS-specific, while $PRINTER works in both major printing systems (CUPS and LPRng).

Reply

Sean Carlos August 21, 2006 at 11:47 pm

… and the CUPS settings web interface is probably available using:

http://localhost:631/admin

Reply

Mike Hearn August 22, 2006 at 10:03 am

What’s wrong with using the GUI? At least on my system (and any modern GNOME desktop will be similar) I clicked “Control Center”, “Printers” and selected “Make Default” from the right click menu of the appropriate printer.

Reply

PuzZler August 22, 2006 at 5:37 pm

Isn’t linux that BSD clone for beginners? :->

Reply

Joseph Hunkins August 22, 2006 at 9:48 pm

Wow – this post is not yet two days old and it’s top for “default printer firefox” and 8th for “Default Printer”!

Reply

Alan Perkins August 23, 2006 at 3:56 am

> environmental variable

An ecologically sound entity.

Reply

PuzZler August 23, 2006 at 3:59 am

This site is a total exception and can not be copied in its behaviour (legally :) . Thousands of webmasters link here, thousands of “news sites” and scrapers link here (even if google does not show the backlinks, yahoo siteexplorer shows over 80,000 inlinks, except from this domain).

if you would have 80,000 inlinks you would probably be all over the place for your keywords as well.

Reply

Joseph Hunkins August 23, 2006 at 1:33 pm

Puzzler – Good points, though I was surprised how well my lowly blog posts were doing for several specific searches until recent indexing problems that appear to be WordPress related. The key questions are not backlink related, they are “what is the most relevant page for this query and is Google showing that page as the top”? Google does OK but not great using this measure.

Reply

Bob Mutch September 1, 2006 at 3:47 pm

Hey Matt why don’t you put the article title in the title tag first instead of “Matt Cutts: Gadgets, Google, and SEO »”.

Even if you think it doesn’t matter for ranking weight and you don’t care where you rank, I think a title like “Changing the default printer on Linux and Firefox » Matt Cutts …” is going to help the human consumer more that “Matt Cutts: Gadgets, Google, and SEO » Changing the default …”

Looks like you could use a bit of SEO help : )

Reply

Tony Lawrence November 8, 2006 at 11:56 am

On some Unix systems, LPDEST is the variable to export.

On most Unixish systems, “lpadmin -d printername” sets the default printer – I think CUPS respects that also.

On Mac OS X, you can set environment variables for apps that don’t have a shell: see http://aplawrence.com/MacOSX/secret_stuff.html

Reply

Bob Maple May 4, 2007 at 2:04 pm

THANK YOU!

My God, why is it so hard to figure out these things? Can’t someone just write programs people can use?

CUPSD? What does that even mean? Was it named by oversexed, pimply-faced 14 years olds boys?

Sorry, needed to vent. It shouldn’t be this hard to set a default printer. You should just have to type in “CUPS default printer” and just see the answer in the first google thing. And programs shouldn’t have stupid, obscure names. CUPSD? GIMP? Who names this stuff?

Reply

oyun July 6, 2007 at 7:16 am

That’s way too easy. Where is the challenge in that? There must be a more complicated way to get something to print.

Reply

Anthony Bradley July 21, 2007 at 2:27 pm

Weren’t computers invented to do the complex stuff for us mere mortals? So, why is it that some people persist in making them harder to understand and use, and worse still wanting it that way?

If the geeks are so smart then make computers truly easy to use. Normal people don’t have the time to learn strange syntax just to print something.

That is why Linux is not adopted by the masses.

Reply

oyun October 16, 2007 at 1:18 pm

That’s way too easy. Where is the challenge in that? There must be a more complicated way to get something to print.
Yes her road must become for me

Reply

indir November 5, 2007 at 9:28 am

Puzzler – Good points, though I was surprised how well my lowly blog posts were doing for several specific searches until recent indexing problems that appear to be WordPress related. The key questions are not backlink related, they are “what is the most relevant page for this query and is Google showing that page as the top”? Google does OK but not great using this measure.

Reply

Michael Thomas November 27, 2007 at 8:06 pm

Bob Marker,

GIMP, yeah, that name is stupid isn’t it, I wonder why in the hell the Gnu Image Manupilation Project would call their program GIMP. And CUPS I suppose is equally as strange. Why should the Common Unix Printer Service have such a silly name!

Reply

Anne Scoffield December 6, 2007 at 12:57 am

This is it! I’m using ubuntu now, this page will be a great help!

Reply

kral oyun January 6, 2008 at 8:23 am

that works, unless you want the default printer to be generic postscript and then firefox doesn’t seem to be able to remember that at all.

Reply

Gowthaman July 15, 2009 at 9:53 am

Start -> system -> prefernce->more prefernce -> printer
brings all the 28 printers we have in the building……(also highlights the current default printer). just change it you are good to go…………

and this is Cent OS

Reply

Charlie McBride January 20, 2010 at 6:04 am

Hi, my name is Charlie and I am a web master that is a Linux fanatic. I remember a while back, searching goggle for Linux printer help. I think I remember seeing this blog somewhere along the way and did not know who Matt Cuts was than, sorry. Now I do, and that is very cool and so is Matt.
I understand how difficult Linux can be for some people, and I like helping people

Charlie

Reply

Rich February 10, 2010 at 10:59 am

The file modified by lpoptions is ~/.lpoptions, unless you run as root, then it’s /etc/cups/lpoptions. See man lpoptions for details.

Reply

Nathan December 1, 2010 at 11:26 am

I nevery thought of using the phrase “How to” as a tag or category. Is that something you recommend using for a lot of posts?

Reply

John Taylor January 29, 2011 at 7:43 am

I can never remember Linux syntax… it all seems to awk for me

awk ‘{ print “value is ‘”‘”‘” $akward “‘”‘”‘” }’ input.geeks

Reply

Leave a Comment

If you have a question about your site specifically or a general question about search, your best bet is to post in our Webmaster Help Forum linked from http://google.com/webmasters

If you comment, please use your personal name, not your business name. Business names can sound salesy or spammy, and I would like to try people leaving their actual name instead.

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: