|

Linux CLI 52 ๐Ÿง lpstat, lpq and lprm commands

lpstat -a
lpstat -p
lpstat -d
lpstat -s

lpq -P canon
lpq -l -P canon
lprm 345
lprm -P canon 345
lprm -P canon 345 -

These three commands are the print management trio on Linux. lpstat tells you about the printers โ€” which ones exist, which are accepting jobs, which is the default. lpq shows you the queue โ€” what’s waiting to print. lprm lets you remove jobs from the queue.

Key point: All three work with CUPS (Common UNIX Printing System). They’re the System V-style management commands that pair with lp, though lprm and lpq come from the Berkeley tradition. Together they give you complete visibility and control over printing.


a – lpstat command

lpstat provides information about the status of the printers. It’s the first command you run when something isn’t printing โ€” it tells you whether the printer exists, is accepting jobs, and is the default.

Common options:

OptionPurpose
-aShow accepting state of printers
-pShow all printers
-dShow current default destination
-sShow a status summary
-vShow printers’ attached devices
-oShow all jobs
-rShow whether the CUPS scheduler is running
-tShow all status info
-lLong/verbose output

Examples:

# Show accepting state of printers
$ lpstat -a
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
hp accepting requests since Mon 15 Jan 2024 09:00:00 AM UTC

# Show all printers
$ lpstat -p
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC
printer hp is idle.  enabled since Mon 15 Jan 2024 09:00:00 AM UTC

# Show current default destination
$ lpstat -d
system default destination: canon

# Show a status summary
$ lpstat -s
system default destination: canon
members of class canon:
canon
hp
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print

# Show attached devices
$ lpstat -v
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print

# Show all jobs
$ lpstat -o
canon-1234              kronos            1024   Mon 15 Jan 2024 10:00:00 AM UTC
canon-1235              kronos            2048   Mon 15 Jan 2024 10:01:00 AM UTC

# Check if CUPS is running
$ lpstat -r
scheduler is running

# Full status
$ lpstat -t
scheduler is running
system default destination: canon
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC
canon-1234              kronos            1024   Mon 15 Jan 2024 10:00:00 AM UTC

# Verbose output
$ lpstat -l -p
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC
	Form mounted:
	Content types: any
	Printer types: unknown
	Description: Canon Printer
	Location:
	Interface: /etc/cups/ppd/canon.ppd
	On fault: no alert
	After fault: continue
	Users allowed:
		(all)
	...

Reading lpstat output:

FieldMeaning
accepting requestsPrinter is enabled and taking jobs
idleNo active job
printingCurrently printing
disabledPrinter is turned off for jobs
system default destinationDefault printer for lp/lpr
device forConnection URI (USB, IPP, network)

Common diagnostic checks:

# Is CUPS running?
$ lpstat -r
scheduler is running

# What printers exist?
$ lpstat -a
canon accepting requests since ...

# What's the default?
$ lpstat -d
system default destination: canon

# Is my printer accepting jobs?
$ lpstat -p canon
printer canon is idle.  enabled since ...

# What jobs are pending?
$ lpstat -o
canon-1234              kronos            1024   ...

b – lpq command

lpq shows the current print queue status. It provides information about jobs that are currently waiting to be printed โ€” who submitted them, their size, and their position in the queue.

Common options:

OptionPurpose
-aShow jobs on all printers
-lVerbose report
-P PRINTERSpecify an alternative printer
-U USERShow jobs for a specific user
+ INTERVALContinuously refresh every N seconds

Examples:

# Show queue for the default printer
$ lpq
canon is ready
no entries

# Show queue for a specific printer
$ lpq -P canon
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes
2nd     alice   1236    notes.txt                       1024 bytes

# Verbose output
$ lpq -l -P canon
canon is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes
2nd     alice   1236    notes.txt                       1024 bytes

kronos: active                           [job 1234 canon]
        report.pdf                       45678 bytes
kronos: 1st                              [job 1235 canon]
        file2.txt                        2048 bytes
alice:  2nd                              [job 1236 canon]
        notes.txt                        1024 bytes

# Show all printers
$ lpq -a
Rank    Owner   Job     File(s)                         Total Size
canon:
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes

hp:
no entries

# Show only your jobs
$ lpq -U kronos
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes

# Continuous refresh every 5 seconds
$ lpq +5

Reading lpq output:

FieldMeaning
RankPosition in queue (active = printing now)
OwnerUser who submitted the job
JobJob ID (use this with lprm)
File(s)Filename(s) being printed
Total SizeSize in bytes

lpq vs lpstat -o:

Aspectlpqlpstat -o
StyleBerkeleySystem V
OutputQueue with ranksJob list
Shows activeYesYes
Shows printer statusYesVia -p
Job IDsYesYes

Both show the same jobs. lpq emphasizes the queue order, lpstat -o gives a cleaner list.


c – lprm command

lprm removes jobs from the print queue. It allows you to cancel print jobs that are pending or being processed.

Common options:

OptionPurpose
-P PRINTERSpecify the printer
-U USERSpecify the user
-h SERVERSpecify a server
-Remove all jobs (for that printer/user)
(no args)Cancel the current job

Examples:

# Remove job 345
$ lprm 345
# Job 345 removed

# Remove job 345 from a specific printer
$ lprm -P canon 345
# Job 345 removed from canon

# Remove all jobs for a printer
$ lprm -P canon -
# All jobs removed from canon

# Remove your own current job
$ lprm
# Current job cancelled

# Remove all of your jobs
$ lprm -
# All your jobs removed

# Remove all jobs for a specific user (as root)
$ sudo lprm -U alice -
# All of alice's jobs removed

# Remove from a remote server
$ lprm -h printserver -P canon 345

# Remove all jobs on all printers (as root)
$ sudo lprm -a -

What the arguments mean:

CommandEffect
lprmCancel the current job
lprm -Cancel all your jobs
lprm 345Cancel job 345
lprm -P canon 345Cancel job 345 on canon
lprm -P canon -Cancel all jobs on canon
lprm -U alice -Cancel all of alice’s jobs

System V alternative โ€” cancel:

# Cancel job 345
$ cancel 345
# or
$ cancel canon-345

# Cancel all jobs on canon
$ cancel -a canon

lprm vs cancel:

Aspectlprmcancel
StyleBerkeleySystem V
By IDlprm 345cancel 345
By printer-P canon-a canon
All jobs--a
All printers-a --a

Complete Example Session

# ============================================
# PART 1: CHECK PRINTER STATUS
# ============================================

$ lpstat -a
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
hp accepting requests since Mon 15 Jan 2024 09:00:00 AM UTC

$ lpstat -p
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC
printer hp is idle.  enabled since Mon 15 Jan 2024 09:00:00 AM UTC

$ lpstat -d
system default destination: canon

$ lpstat -s
system default destination: canon
members of class canon:
canon
hp
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print

# ============================================
# PART 2: FULL STATUS CHECK
# ============================================

$ lpstat -t
scheduler is running
system default destination: canon
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC
canon-1234              kronos            1024   Mon 15 Jan 2024 10:00:00 AM UTC

# ============================================
# PART 3: SUBMIT JOBS
# ============================================

$ lpr -P canon report.pdf
$ lpr -P canon file2.txt
$ lpr -P canon notes.txt

$ lpr -P hp presentation.pdf

# ============================================
# PART 4: CHECK THE QUEUE
# ============================================

$ lpq -P canon
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes
2nd     kronos  1236    notes.txt                       1024 bytes

$ lpq -P hp
hp is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1237    presentation.pdf                87654 bytes

# Verbose
$ lpq -l -P canon
canon is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes
2nd     kronos  1236    notes.txt                       1024 bytes

kronos: active                           [job 1234 canon]
        report.pdf                       45678 bytes
kronos: 1st                              [job 1235 canon]
        file2.txt                        2048 bytes
kronos: 2nd                              [job 1236 canon]
        notes.txt                        1024 bytes

# All printers
$ lpq -a
Rank    Owner   Job     File(s)                         Total Size
canon:
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes
2nd     kronos  1236    notes.txt                       1024 bytes

hp:
active  kronos  1237    presentation.pdf                87654 bytes

# ============================================
# PART 5: REMOVE JOBS
# ============================================

# Remove job 1235 from canon
$ lprm -P canon 1235
# Job 1235 removed

$ lpq -P canon
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1236    notes.txt                       1024 bytes

# Remove all jobs on canon
$ lprm -P canon -
# All jobs removed from canon

$ lpq -P canon
canon is ready
no entries

# ============================================
# PART 6: CHECK WITH LPSTAT
# ============================================

$ lpstat -o
canon-1237              kronos            87654   Mon 15 Jan 2024 10:05:00 AM UTC

$ lpstat -o canon
canon-1237              kronos            87654   Mon 15 Jan 2024 10:05:00 AM UTC

# ============================================
# PART 7: CANCEL WITH SYSTEM V
# ============================================

# Cancel job 1237
$ cancel 1237
# Job 1237 cancelled

# Cancel all jobs on hp
$ cancel -a hp
# All jobs cancelled on hp

# ============================================
# PART 8: FINAL CHECK
# ============================================

$ lpstat -o
# (no output โ€” queue is empty)

$ lpq -a
Rank    Owner   Job     File(s)                         Total Size
canon:
no entries

hp:
no entries

Quick Reference

lpstat

CommandPurpose
lpstat -aShow accepting state
lpstat -pShow all printers
lpstat -dShow default printer
lpstat -sStatus summary
lpstat -vShow devices
lpstat -oShow all jobs
lpstat -rScheduler status
lpstat -tFull status
lpstat -lVerbose

lpq

CommandPurpose
lpqQueue for default printer
lpq -P PRNQueue for specific printer
lpq -aQueue for all printers
lpq -lVerbose output
lpq -U USERJobs for a user
lpq +NRefresh every N seconds

lprm

CommandPurpose
lprmCancel current job
lprm -Cancel all your jobs
lprm JOBCancel job by ID
lprm -P PRN JOBCancel job on printer
lprm -P PRN -Cancel all on printer
lprm -U USER -Cancel all of user’s jobs
lprm -a -Cancel all jobs (root)

cancel (System V)

CommandPurpose
cancel JOBCancel job by ID
cancel PRN-JOBCancel with printer
cancel -a PRNCancel all on printer
cancel -aCancel all jobs

Printer Status Meanings

StatusMeaning
idleNo active job
printingCurrently printing
disabledNot accepting jobs
accepting requestsTaking jobs
scheduler is runningCUPS is up

Best Practices

โœ… Do This:

# Start with lpstat to see what exists
lpstat -a                             # โœ…

# Check the default printer
lpstat -d                             # โœ…

# Check the queue before printing
lpq                                   # โœ…

# Use -P to be explicit
lpq -P canon                          # โœ…

# Cancel by job ID from lpq
lprm -P canon 1235                    # โœ…

# Use lpstat -t for a full picture
lpstat -t                             # โœ…

# Check CUPS is running if nothing prints
lpstat -r                             # โœ…

# Use cancel -a to clear a stuck printer
cancel -a canon                       # โœ…

โŒ Don’t Do This:

# Don't run lprm without checking first
lprm -                                # โš ๏ธ  cancels all your jobs

# Don't guess job IDs
lprm 1234                             # โš ๏ธ  check lpq first

# Don't use lprm -a as regular user
lprm -a -                             # โŒ needs root

# Don't ignore a disabled printer
lp file.txt                           # โš ๏ธ  check lpstat -p first

# Don't confuse lpq and lpstat
lpq                                   # โœ… queue
lpstat -o                             # โœ… jobs
lpq -o                                # โŒ no -o option

# Don't forget -P when multiple printers exist
lprm 1234                             # โš ๏ธ  which printer?

Common Pitfalls

PitfallProblemSolution
CUPS not runningNothing workssudo systemctl start cups
Printer disabledJobs queue forevercupsenable PRN
Wrong job IDCan’t cancelCheck lpq first
lprm -Cancels all your jobsUse specific IDs
No -PWrong printerSpecify explicitly
Stale jobsQueue stuckcancel -a PRN
Permission deniedCan’t cancel othersUse sudo
lpstat emptyNo printers configuredlpadmin or CUPS web UI

Real-World Examples

1. Check All Printers

$ lpstat -a
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
hp accepting requests since Mon 15 Jan 2024 09:00:00 AM UTC

2. Find the Default Printer

$ lpstat -d
system default destination: canon

3. Full Printer Status

$ lpstat -t
scheduler is running
system default destination: canon
device for canon: ipp://canon.local:631/ipp/print
canon accepting requests since Mon 15 Jan 2024 10:00:00 AM UTC
printer canon is idle.  enabled since Mon 15 Jan 2024 10:00:00 AM UTC

4. Check the Queue

$ lpq
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes
1st     kronos  1235    file2.txt                       2048 bytes

5. Check Queue for a Specific Printer

$ lpq -P canon
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes

6. Verbose Queue

$ lpq -l -P canon
canon is ready and printing
...
kronos: active                           [job 1234 canon]
        report.pdf                       45678 bytes

7. Show All Queues

$ lpq -a
Rank    Owner   Job     File(s)                         Total Size
canon:
active  kronos  1234    report.pdf                      45678 bytes
hp:
no entries

8. Cancel a Job

$ lprm -P canon 1235
# Job 1235 removed

9. Cancel All Jobs on a Printer

$ lprm -P canon -
# All jobs removed from canon

10. Cancel with System V Style

$ cancel 1235
# Job 1235 cancelled

$ cancel -a canon
# All jobs on canon cancelled

11. Check Your Own Jobs

$ lpq -U kronos
canon is ready
Rank    Owner   Job     File(s)                         Total Size
active  kronos  1234    report.pdf                      45678 bytes

12. Monitor the Queue Continuously

$ lpq +5
# Refreshes every 5 seconds

13. Check if CUPS Is Running

$ lpstat -r
scheduler is running

14. Show All Jobs Across Printers

$ lpstat -o
canon-1234              kronos            45678   Mon 15 Jan 2024 10:00:00 AM UTC
hp-1237                 kronos            87654   Mon 15 Jan 2024 10:05:00 AM UTC

15. Emergency โ€” Clear All Your Jobs

$ lprm -
# All your jobs cancelled

16. Admin โ€” Clear a Printer Completely

$ sudo cancel -a canon
# All jobs on canon cancelled

17. Check Remote Server

$ lpq -h printserver -P canon

18. Show Devices

$ lpstat -v
device for canon: ipp://canon.local:631/ipp/print
device for hp: ipp://hp.local:631/ipp/print

19. Watch a Job Progress

$ while lpq -P canon | grep -q 1234; do
    lpq -P canon
    sleep 2
  done
echo "Job complete"

20. Discover Printers via lpinfo

$ lpinfo -v
network ipp
network ipps
direct usb://Canon/MF210
network socket
...

Visual: Print Management

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Print management flow              โ”‚
โ”‚                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  lpstat  โ†’  what printers exist?       โ”‚  โ”‚
โ”‚  โ”‚  lpq     โ†’  what's waiting to print?   โ”‚  โ”‚
โ”‚  โ”‚  lprm    โ†’  cancel a job               โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                              โ”‚
โ”‚  Typical workflow:                           โ”‚
โ”‚                                              โ”‚
โ”‚  1. lpstat -a       โ† list printers          โ”‚
โ”‚  2. lpstat -d       โ† find default           โ”‚
โ”‚  3. lp file.txt     โ† submit job             โ”‚
โ”‚  4. lpq             โ† check queue            โ”‚
โ”‚  5. lprm 1234       โ† cancel if needed       โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           The print queue                    โ”‚
โ”‚                                              โ”‚
โ”‚  Rank    Owner   Job     File(s)     Size    โ”‚
โ”‚  โ”€โ”€โ”€โ”€    โ”€โ”€โ”€โ”€โ”€   โ”€โ”€โ”€     โ”€โ”€โ”€โ”€โ”€โ”€โ”€     โ”€โ”€โ”€โ”€    โ”‚
โ”‚  active  kronos  1234    report.pdf  45K     โ”‚  โ† printing now
โ”‚  1st     kronos  1235    file2.txt   2K      โ”‚
โ”‚  2nd     alice   1236    notes.txt   1K      โ”‚
โ”‚                                              โ”‚
โ”‚  lprm 1234  โ†’ cancel the active job          โ”‚
โ”‚  lprm -     โ†’ cancel all your jobs           โ”‚
โ”‚                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

CommandPurposeExample
lpstat -aAccepting statelpstat -a
lpstat -pAll printerslpstat -p
lpstat -dDefault printerlpstat -d
lpstat -sStatus summarylpstat -s
lpstat -vShow deviceslpstat -v
lpstat -oAll jobslpstat -o
lpstat -rScheduler statuslpstat -r
lpstat -tFull statuslpstat -t
lpqDefault queuelpq
lpq -P PRNSpecific printer queuelpq -P canon
lpq -aAll queueslpq -a
lpq -lVerbose queuelpq -l -P canon
lpq -U USERJobs for a userlpq -U kronos
lprm JOBCancel joblprm 345
lprm -P PRN JOBCancel on printerlprm -P canon 345
lprm -P PRN -Cancel all on printerlprm -P canon -
lprm -Cancel all your jobslprm -
cancel JOBCancel (SysV)cancel 345
cancel -a PRNCancel all (SysV)cancel -a canon

Key takeaways:

  • lpstat tells you about printers โ€” -a accepting, -p all, -d default, -s summary, -t full
  • lpq shows the queue โ€” use -P for a specific printer, -l for verbose, -a for all
  • lprm removes jobs โ€” by ID, by printer, or all with -
  • cancel is the System V equivalent โ€” cancel JOB or cancel -a PRN
  • Always run lpstat -a first to see what printers exist
  • Always run lpq before cancelling โ€” get the job ID right
  • Use lpstat -r to check if CUPS is running when nothing prints
  • Use -P to be explicit when multiple printers exist
  • lprm - cancels all your jobs; lprm -a - (as root) cancels everyone’s
  • cancel -a PRN is the fastest way to clear a stuck printer queue

Remember: lpstat is your status tool, lpq is your queue tool, lprm is your cancel tool. Together they give you full control over printing on Linux. Start with lpstat -a to see what’s available, lpstat -d to find the default, lpq to see what’s pending, and lprm to clean up. When a printer gets stuck, cancel -a PRN clears the queue and gets you printing again. Master these three, and printing stops being a black box.


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!