Why Clear the Print Queue via Terminal?
Ubuntu utilizes the Common UNIX Printing System (CUPS) to manage printers and print jobs. Occasionally, a print job can become corrupted or a printer might go offline mid-transfer, causing the job to get permanently stuck in the queue. When this happens, it blocks all subsequent print jobs from processing. While Ubuntu offers a graphical printer management tool, the GUI can sometimes freeze or fail to properly communicate with the CUPS daemon when a job is deeply stuck. In these situations, using the Terminal is the fastest and most forceful way to clear the queue and get your printer working again.
Step 1: View the Current Print Queue
Before deleting jobs, it is helpful to see exactly what is stuck in the queue and identify the job ID numbers.
- Open your Terminal application (Ctrl + Alt + T).
- To view the list of all active print jobs across all connected printers, type the following command and press Enter:
lpstat -o- The output will list the jobs. Note the job ID, which is usually a number following the printer name (e.g.,
HP-LaserJet-123).
Step 2: Cancel a Specific Print Job
If you only want to cancel one specific stuck job while leaving the rest of the queue intact, use the cancel command followed by the job ID.
- Type the command using the ID you found in the previous step:
cancel HP-LaserJet-123- Press Enter. If the job was successfully removed, the command will execute silently.
Step 3: Force Clear the Entire Print Queue
If the queue is hopelessly jammed, or if multiple jobs are stuck, the most efficient method is to cancel every pending job on the system simultaneously.
- To clear all print jobs for all printers, use the
cancelcommand with the-a(all) flag: cancel -a- Press Enter. This command immediately flushes the entire CUPS spooler.
Step 4: Restart the CUPS Service (If Necessary)
In rare cases, the CUPS printing service itself may crash, meaning the queue will clear but new jobs still won’t print. If clearing the queue did not resolve your printing issue, restart the CUPS daemon.
- Run the following command to restart the service:
sudo systemctl restart cups - Enter your administrator password when prompted. Once the service restarts, try printing your document again.