Linux Hands-On Lab - Working with the CUPS Print Server

Linux Hands-On Lab - Working with the CUPS Print Server

Linux Learning Path for Cloud and DevOps Engineers

📝Introduction

A Linux system administrator should have a basic understanding of the CUPS print server.

In this hands-on lab, we will practice with a newly installed print server that will send jobs to PDF files. We will use the lpd (line print daemon) toolset provided by a CUPS installation.

These are the objectives of this lab:

  • Install a PDF printer.

  • Print a test page.

  • Modify the printer and work with the print queue.

📝Log in to the AWS Management Console

Using your credentials, make sure you're using the right Region. In my case, I am using AWS as my cloud provider and chose us-east-1. However, you can choose any cloud provider and create your Linux Server VM (I am using a CentOS 7 distro) for this hands-on lab.

📌Note: You must create the AWS Access Key and AWS Secret Access Key and configure the AWS CLI in the terminal to use it.

You can use link1 and link2 for it.

📝Install a PDF Printer

Open your terminal application. Check to see which printers are installed.

lpstat -s

Check to see what types of printer connections are available.

sudo lpinfo -v

Install a PDF printer to use with CUPS.

sudo lpadmin -p CUPS-PDF -v cups-pdf:/

Determine which driver files we can use with our printer by querying the CUPS database for files that contain "PDF".

lpinfo --make-and-model "PDF" -m

Use CUPS-PDF.ppd as the driver file.

sudo lpadmin -p CUPS-PDF -m "CUPS-PDF.ppd"

Run the lpstat command again.

lpstat -s

Check the status of the printer we just installed.

lpc status

Enable the printer to accept jobs, and set it up as the default printer.

sudo lpadmin -d CUPS-PDF -E
sudo cupsenable CUPS-PDF
sudo cupsaccept CUPS-PDF

Run the lpc status command again.

lpc status

The printer should now be ready.

📝Print a Test Page

Print a copy of the /etc/passwd file to a PDF file in our home directory.

lpr /etc/passwd

Verify that there is a copy of the /etc/passwd file in the home directory.

ls

📝Modify the Printer and Work with the Print Queue

Configure the printer so that it will not accept any new jobs.

sudo cupsreject CUPS-PDF

Verify the status of the printer.

lpc status

Attempt to print the /etc/group file to the printer.

lpr /etc/group

You should receive a message that says the printer is not currently accepting jobs.

Reconfigure the printer to once again accept incoming jobs.

sudo cupsaccept CUPS-PDF

Check the status of the printer.

lpc status

Configure the printer so that it accepts jobs to its queue but will not print them.

sudo cupsdisable CUPS-PDF

Check the status of the printer.

lpc status

Attempt to print the /etc/group file again.

lpr /etc/group

List the contents of the /home directory.

ls

Check the printer's queue.

lpq

Remove the job from the printer's queue (remember to substitute the job ID from your command's output).

lprm <JOB_ID>

Verify that the job was successfully removed from the printer's queue.

lpq

Re-enable the printer's ability to print new jobs.

sudo cupsenable CUPS-PDF

Verify that the CUPS-PDF printer is once again ready to accept new jobs.

lpq

📌Note - At the end of each hands-on Lab, always clean up all the resources previously created to avoid being charged if you used a Cloud Provider to provision them.

Congratulations — you have completed this hands-on lab covering the basics of working with the CUPS Print Server in Linux.

Thank you for reading. I hope you understood and learned something helpful from my blog.

Please follow me on CloudDevOpsToLearn and LinkedIn, franciscojblsouza