How to print from the command line

Printing from the command line can let you get things done very quickly. It can also open up a world of one-click printing of files, which we’ll get into with a future post. So, to get started, navigate to http://localhost:631 in your browser. If you have a default Ubuntu installation, you should now be looking at your CUPS (formerly Common Unix Printing System) page.

Once there you’ll need to go into the Command-Line Printing and Options page. Its here that we find the instructions we need. Now, printing a file from the command line may be as simple as running one command. Here’s what this page has to say about this process.

CUPS understands many different types of files directly, including text, PostScript, PDF, and image files. This allows you to print from inside your applications or at the command-line, whichever is most convenient! Type either of the following commands to print a file to the default (or only) printer on the system:

lp filename
lpr filename

If you only have one printer on your system, that’s probably all you’ll need. You may however, have to tell CUPS which is your default printer. CUPS tells us how to do this as well. The first thing you need to do is find out the name of your printer. Here’s how you can do this.

lpstat -p -d

Now you have the name of your printer(s). Choose the one you want to primarily use, with this command.

lpoptions -d printername

Now, when you run your lp or lpr command to print a file, CUPS knows which printer to send the job to. There are tons of other options, all laid out on the Command-Line Printing and Options page. Keep in mind that all of this info assumes that you already have the requisite print drivers installed and configured on your system.

Command-Line Printing and Options

  • Share/Bookmark

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>