CloudAcademy
  1. Home
  2. Training Library
  3. Cloud Computing Fundamentals
  4. Courses
  5. LPIC-1 102 Linux certification - Linux System Services (4 of 6)

Printers

The course is part of this learning path

Contents

keyboard_tab
Course Introduction
Linux Services
3
Logging6m 14s
4
Mail5m 10s
5
Printers4m 46s
play-arrow
Start course
Overview
DifficultyIntermediate
Duration25m
Students471

Description

This is the fourth of a total of six courses covering the 102 exam of the LPIC-1 Linux Server Professional certification. You'll learn about managing key Linux system services, including:

  • System time: how to stay in sync with Stratum One NTP time servers.
  • Logging: how to use logs to monitor your system for security and performance considerations
  • Email: create and manage email accounts, forwarders, and aliases.
  • Printing: configure and manage printers and print jobs

If you have thoughts or suggestions for this course, please contact Cloud Academy at support@cloudacademy.com.

Transcript

Using CUPS to manage Linux printers

Along with printers themselves, the way Linux manages printing has evolved over the last 20 years. We'll look at the command line printing tools a bit later, but these days your primary connection to printer drivers and configuration comes through CUPS, the Common Unix Printing System, and your primary CUPS interface works through a browser via the address local host:631. Oddly enough, the CUPS package is managed by Apple. Yes, that Apple. Most Linux distributions have graphic software tools to manage printing, but they're really just front ends to the CUPS server. The main CUPS configuration file, /etc/cups/cupsd.conf can be viewed and edited in the command line, but it is also accessible through the Edit Configuration File link in the admin tab.

The admin tab also provides links to help you add and manage printers, and manage print jobs. Clicking on add class allows you to create and manage printer classes. A printer class is a group of printers that are all equally accessible. When a job is directed to the group, it'll be sent to the first available printer.

Managing printers from the Linux command line

Should the need arise, you can actually print from the terminal either existing files or command line text itself. The good news is that the LP program draws its settings from your CUPS configuration and knows all about your printer and its drivers. Once again, if you're not sure why you'd ever want to print from the command line, just remember that Bash scripts can come will all kinds of strange use cases. But even better, it can be a really fun way to scare the daylights out of some guy dozing off at his workstation a few offices down.

At any rate, you can print using LP or LPR followed by a filename. If you've got more than one printer associated with your computer, you can specify it by adding a -d switch followed by the name of the printer driver. This is a driver from my Brother laser printer. You can also print directly from the command line by leaving the filename out altogether. You enter the text you'd like printed on subsequent lines and complete the job with control+d.

To view the jobs pending in your print queue, use LPQ or lpstat. The jobs we just created are still in the queue because my printer happens to be turned off right now. If you'd like to delete a print job, note its job number from LPQ and use LPRM. To remove all jobs in the queue, type the minus sign in place of a job number. Running LPQ again shows us that the queue is now empty. You can use LPQ and LPRM to work with all system print jobs even those launched from GUI applications.

As is true of pretty much all Linux processes, your first front line tool for troubleshooting print jobs or printer drivers that aren't working the way they should is logs. While the most current printer log files are available from the CUPS browser console, if you need to see older, backup versions, you'll need to go to the /var/log/cups directory. The two log types we're interested in are access log and error log. Incidentally you can quickly view the older compressed .gc backup files without having to actually decompress them by using zcat or zless. If you want your printer to reject all new jobs sent to it, you can use CUPS reject.

If you want to open the printer up to new jobs, use CUPS accept. Let's review. The Common Unix Printing System accessible through local host:631 is a browser interface for managing printers, printer classes, and jobs. You can also control your printer from the command line. LP and a filename will print a file.

LPQ will display the print queue. LPRM will delete a print job. Print-related logs are kept in the /var/log/cups directory. CUPS reject will reject new jobs, and CUPS accept will reopen the printer to new jobs.

About the Author

Students15422
Courses17
Learning paths2

David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.

Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.

Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.

His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.

Covered Topics