Changing the default printer on Linux and Firefox

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.

Related Posts:

23 Comments »

  1. Aaron Pratt Said,

    August 21, 2006 @ 3:33 pm

    And that is why people still use Windows! :)

    Welcome back Matt.

  2. Scott S. Said,

    August 21, 2006 @ 4:28 pm

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

  3. Hawaii SEO Said,

    August 21, 2006 @ 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. :)

  4. David Maple Said,

    August 21, 2006 @ 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.

  5. ark Said,

    August 21, 2006 @ 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.

  6. Andrew Said,

    August 21, 2006 @ 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).

  7. Sean Carlos Said,

    August 21, 2006 @ 11:47 pm

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

    http://localhost:631/admin

  8. Mike Hearn Said,

    August 22, 2006 @ 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.

  9. PuzZler Said,

    August 22, 2006 @ 5:37 pm

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

  10. Joseph Hunkins Said,

    August 22, 2006 @ 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”!

  11. Alan Perkins Said,

    August 23, 2006 @ 3:56 am

    > environmental variable

    An ecologically sound entity.

  12. PuzZler Said,

    August 23, 2006 @ 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.

  13. Joseph Hunkins Said,

    August 23, 2006 @ 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.

  14. Bob Mutch Said,

    September 1, 2006 @ 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 : )

  15. Tony Lawrence Said,

    November 8, 2006 @ 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

  16. Bob Maple Said,

    May 4, 2007 @ 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?

  17. oyun Said,

    July 6, 2007 @ 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.

  18. Anthony Bradley Said,

    July 21, 2007 @ 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.

  19. oyun Said,

    October 16, 2007 @ 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

  20. indir Said,

    November 5, 2007 @ 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.

  21. Michael Thomas Said,

    November 27, 2007 @ 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!

  22. Anne Scoffield Said,

    December 6, 2007 @ 12:57 am

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

  23. kral oyun Said,

    January 6, 2008 @ 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.

RSS feed for comments on this post

Got a webmaster-related question or suggestion that is not directly related to the topic of this entry? Instead of posting it here, your best bet is our official Google forum linked from http://www.google.com/webmasters/

Also, I pre-moderate first-time commenters. Please review my comment policy before leaving a comment.