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.

28 Responses to Changing the default printer on Linux and Firefox (Leave a comment)

  1. And that is why people still use Windows! :)

    Welcome back Matt.

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

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

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

    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

    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. … and the CUPS settings web interface is probably available using:

    http://localhost:631/admin

  8. 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. Isn’t linux that BSD clone for beginners? :->

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

  11. > environmental variable

    An ecologically sound entity.

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

    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. That’s way too easy. Where is the challenge in that? There must be a more complicated way to get something to print.

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

    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. This is it! I’m using ubuntu now, this page will be a great help!

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

  24. Gowthaman

    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

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

  26. Rich

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

  27. 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?

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

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

Leave a Comment

Your email address will not be published. Required fields are marked *

*

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 may 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>

css.php