Introduction
This tutorial guides you through using the lpq
command in Linux to effectively monitor and control your printing workflow. Learn how to check the print queue status, understand print job details, and manage print jobs directly from the command line. This resource provides a clear and concise explanation of the lpq
command, enabling systemadmin to streamline print management tasks. Follow the easy-to-understand steps to master print queue management in your Linux environment.
Understand the Purpose and Syntax of the lpq Command
This section delves into the purpose and syntax of the lpq
command within a Linux system. As a systemadmin, understanding this command is crucial for managing print jobs. The lpq
command is your go-to tool for examining the print queue and overseeing print job execution.
Let's begin by dissecting the lpq
command's syntax:
$ lpq [options] [printer]
The lpq
command accepts the following options:
-a
: Shows the status of every print queue currently configured.-l
: Provides a detailed listing that includes crucial information like job IDs, filenames, and the user responsible for the print job.-P <printer>
: Specifies the target printer to check the print queue for, allowing you to focus on specific devices.
Let's put the lpq
command to use by checking the default print queue's status:
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
The output presents a snapshot of the print queue's current state, including the job's position (rank), the user who submitted it (owner), the unique job ID, the file being printed, and its size.
Example output:
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
The next section will guide you in using the lpq
command for a more detailed examination of the print queue status.
Check the Print Queue Status Using the lpq Command
This section focuses on leveraging the lpq
command to gain a more comprehensive understanding of the print queue status. As a systemadmin on a Linux system, this knowledge is invaluable for troubleshooting and managing printing resources.
Let's start by examining the status of the default print queue:
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
The output provides a real-time view of the print jobs awaiting processing, including their position in the queue (rank), the user who initiated the print (owner), the unique identifier for the job (job ID), the file being printed, and the size of the file.
For more in-depth information, use the -l
option to display a long listing:
$ lpq -l
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
labex
1st labex 124 report.docx 2345678 bytes
labex
This detailed listing includes additional details, such as the username associated with each print job.
To specifically check a printer's queue, use the -P
option followed by the printer's name:
$ lpq -P printer1
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
This command displays the status of the print queue for the printer named 'printer1'.
Example output:
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
The following section will instruct you on managing print jobs through the lpq
command, as well as other related utilities.
Manage Print Jobs with the lpq Command
In this section, you'll discover how to take control of print jobs using the lpq
command, along with other complementary tools. As a systemadmin, this capability is essential for maintaining a smooth printing environment for your users.
Begin by checking the print queue's present state:
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
Suppose a print job needs to be canceled. The lprm
command allows you to remove a print job from the queue:
$ lprm 124
This command will remove the print job with ID 124.
Verify the queue's updated status using the lpq
command:
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
The output confirms that job ID 124 has been successfully removed.
To pause or resume print jobs, the lpc
command is used. Note that using `lpc` typically requires root privileges or appropriate systemadmin permissions.
$ lpc hold 123
$ lpq
Rank Owner Job File(s) Total Size
active* labex 123 document.pdf 1234567 bytes
$ lpc release 123
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
The lpc hold
command suspends print job 123. The asterisk (*) next to 'active' indicates the job is on hold. The lpc release
command resumes the print job.
Example output:
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
1st labex 124 report.docx 2345678 bytes
$ lprm 124
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
$ lpc hold 123
$ lpq
Rank Owner Job File(s) Total Size
active* labex 123 document.pdf 1234567 bytes
$ lpc release 123
$ lpq
Rank Owner Job File(s) Total Size
active labex 123 document.pdf 1234567 bytes
This section has provided guidance on how to manage print jobs using lpq
, lprm
, and lpc
commands. Proper use of these commands gives a systemadmin full control over the print queue.
Summary
This tutorial provided a deep dive into the lpq
command in Linux, a vital tool for any systemadmin. You've learned how to check the status of print queues and manage print jobs effectively. The tutorial covered various lpq
options, including displaying all queues, providing detailed job information, and specifying printers. It also demonstrated how to use lpq
to examine the default print queue, revealing key details about print jobs such as rank, owner, job ID, filename, and size. Through this tutorial, you have gained the skills necessary to efficiently monitor and manage printing in your Linux environment.