How To Linux Learn the Linux Command - lp Print files from the Linux command line Share Pin Email Print moodboard/Getty Images Linux Commands Basics Guides & Tutorials Installing & Upgrading Tips & Tricks Key Concepts by Juergen Haas Former Lifewire writer Juergen Haas is a software developer, data scientist, and a fan of the Linux operating system. Updated December 06, 2019 The lp command on Linux is a printer management command that lets you print documents and manage your printers without leaving the terminal. If you're on a desktop, there's probably not much reason to rely on lp. The graphical utilities provided by desktop environments like GNOME and Plasma are much friendlier to navigate and use. That said, if you need to print something from over a network via SSH, or you have a headless server that needs to print, lp is the right tool for the job. Using the lp Command on Linux It's certainly possible to work with lp without knowing the name of your printer, especially if you only have one; however, it's much better to know and specify the printer you're working with. Start by using the 'lpstat' command to list out the printers on your system. lpstat -p -d In the output, you'll find a bunch of information about your printer. The important thing, though, is how the command refers to your printer. That's the name you'll need to use for the lp command. Now, you can take that printer name and use it to print a file from your computer. Use lp along with the '-d' flag followed by the name of your printer. Then, specify the path to your file. lp -d printername ~/Documents/myfile If you need more than one copy of your document, use the '-n' flag to specify how many. lp -d printername -n 5 ~/Documents/myfile Some printers are shared across an office. You can set the priority of your print job to control where in the printer's queue it'll print. Use the '-q' flag followed by a number between 1 and 100. The default is 50. lp -d printername -n 5 -q 75 ~/Documents/myfile The lp command also lets you assign a name to your print job to make it more easily identifiable. Use the '-t' flag, and give it a name in quotes. lp -d printername -t "Super Important Document" -q 100 ~/Documents/myfile The '-o' flag is sort of special. It's a general "options" flag that's mostly used for specifying how you want your document printed. For instance, if you want to print in landscape, you'd use: lp -d printername -o landscape ~/Documents/myfile You can also specify the type of paper that you're printing to. So, if you're working with longer legal paper, you could use: lp -d printername -o media=legal ~/Documents/myfile Like any other options, you can combine them. So, double-sided printing on legal paper would look like: lp -d printername -o media=legal -o sides=two-sided-long-edge ~/Documents/myfile Doing the same in landscape would be: lp -d printername -o media=legal -o landcape -o sides=two-sided-short-edge ~/Documents/myfile The 'two-sided-short' edge option is typically used with landscape, while 'two-sided long-edge' is mostly paired with portrait. Scaling is another common option. While there are plenty of ways to zoom in and out, most people just want to fit their document to the page. The 'fit-to-page' option is there for just that reason. lp -d printername -o media letter -o fit-to-page ~/Documents/myfile That about covers the common uses. For more detailed information, refer to the technical manual below or the manual page on your Linux system. lp Technical Manual Below, you'll find the full technical breakdown of the lp command on Linux Name lp - print filescancel - cancel jobs Synopsis lp [ -E ] [ -c ] [ -d destination ] [ -h server ] [ -m ] [ -n num-copies [ -o option ] [ -q priority ] [ -s ] [ -t title ] [ -H handling ] [ -P page-list ] [ file(s) ]lp [ -E ] [ -c ] [ -h server ] [ -i job-id ] [ -n num-copies [ -o option ] [ -q priority ] [ -t title ] [ -Hhandling ] [ -P page-list ]cancel [ -a ] [ -h server ] [ id ] [ destination ] [ destination-id ] Description lp submits files for printing or alters a pending job. cancel cancels existing print jobs. The -a option will remove all jobs from the specified destination. Options The following options are recognized by lp: -E Forces encryption when connecting to the server. -c This option is provided for backward-compatibility only. On systems that support it, this option forces the print file to be copied to the spool directory before printing. In CUPS, print files are always sent to the scheduler via IPP which has the same effect. -d destination Prints files to the named printer. -h hostname Specifies the print server hostname. The default is "localhost" or the value of the CUPS_SERVER environment variable. -i job-id Specifies an existing job to modify. -m Send email when the job is completed (not supported CUPS 1.1.) -n copies Sets the number of copies to print from 1 to 100. -o option Sets a job option. -q priority Sets the job priority from 1 (lowest) to 100 (highest). The default priority is 50. -s Do not report the resulting job IDs (silent mode.) -t name Sets the job name. -H handling Specifies when the job should be printed. A value of immediate will print the file immediately, a value of hold will hold the job indefinitely, and a time value (HH:MM) will hold the job until the specified time. Use a value of resume with the -i option to resume a held job. -P page-list Specifies which pages to print in the document. The list can contain a list of numbers and ranges (#-#) separated by commas (e.g. 1,3-5,16). Continue Reading