Introduction
In this lab, you will learn how to use the lprm command to remove print jobs from the print queue on a Linux system. The lprm command allows you to remove a specific print job or all print jobs from the queue. You will also learn how to check the current print queue using the lpq command.
The lab covers the following steps: Introduction to the lprm command, Removing a Specific Print Job, and Removing All Print Jobs. The lprm command is a standard Linux command and does not require any additional installation.
Introduction to the lprm Command
In this step, you will learn about the lprm command, which is used to remove print jobs from the print queue on a Linux system. The lprm command allows you to remove a specific print job or all print jobs from the queue.
To begin, let's check the current print queue using the lpq command:
sudo lpq
Example output:
Rank Owner Job File(s) Total Size
active labex 1 document.pdf 1234 bytes
1st labex 2 report.txt 4567 bytes
As you can see, there are two print jobs in the queue, with job IDs 1 and 2.
To remove a specific print job, you can use the lprm command followed by the job ID. For example, to remove job 1, you would run:
sudo lprm 1
Example output:
job "1" dequeued
This will remove the print job with ID 1 from the queue.
If you want to remove all print jobs from the queue, you can use the lprm - command:
sudo lprm -
Example output:
job "2" dequeued
This will remove all print jobs from the queue.
Removing a Specific Print Job
In this step, you will learn how to remove a specific print job from the print queue using the lprm command.
First, let's check the current print queue using the lpq command:
sudo lpq
Example output:
Rank Owner Job File(s) Total Size
active labex 1 document.pdf 1234 bytes
1st labex 2 report.txt 4567 bytes
To remove the print job with ID 2, you can use the following command:
sudo lprm 2
Example output:
job "2" dequeued
This will remove the print job with ID 2 from the queue.
You can verify that the job has been removed by checking the print queue again:
sudo lpq
Example output:
Rank Owner Job File(s) Total Size
active labex 1 document.pdf 1234 bytes
As you can see, the print job with ID 2 has been removed from the queue.
Removing All Print Jobs
In this step, you will learn how to remove all print jobs from the print queue using the lprm command.
First, let's check the current print queue using the lpq command:
sudo lpq
Example output:
Rank Owner Job File(s) Total Size
active labex 1 document.pdf 1234 bytes
1st labex 2 report.txt 4567 bytes
To remove all print jobs from the queue, you can use the following command:
sudo lprm -
Example output:
job "1" dequeued
job "2" dequeued
This will remove all print jobs from the queue.
You can verify that the queue is now empty by checking the print queue again:
sudo lpq
Example output:
no entries
As you can see, the print queue is now empty, and all print jobs have been removed.
Summary
In this lab, you learned how to use the lprm command to remove print jobs from the print queue on a Linux system. You started by introducing the lprm command and checking the current print queue using the lpq command. You then learned how to remove a specific print job by running the lprm command with the job ID. Finally, you discovered how to remove all print jobs from the queue by using the lprm - command.
The key learning points from this lab are:
- The
lprmcommand is used to remove print jobs from the print queue. - You can remove a specific print job by running
lprmwith the job ID. - To remove all print jobs from the queue, you can use the
lprm -command.



