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:
| Option | Purpose |
|---|---|
-a | Show accepting state of printers |
-p | Show all printers |
-d | Show current default destination |
-s | Show a status summary |
-v | Show printers’ attached devices |
-o | Show all jobs |
-r | Show whether the CUPS scheduler is running |
-t | Show all status info |
-l | Long/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:
| Field | Meaning |
|---|---|
accepting requests | Printer is enabled and taking jobs |
idle | No active job |
printing | Currently printing |
disabled | Printer is turned off for jobs |
system default destination | Default printer for lp/lpr |
device for | Connection 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:
| Option | Purpose |
|---|---|
-a | Show jobs on all printers |
-l | Verbose report |
-P PRINTER | Specify an alternative printer |
-U USER | Show jobs for a specific user |
+ INTERVAL | Continuously 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:
| Field | Meaning |
|---|---|
Rank | Position in queue (active = printing now) |
Owner | User who submitted the job |
Job | Job ID (use this with lprm) |
File(s) | Filename(s) being printed |
Total Size | Size in bytes |
lpq vs lpstat -o:
| Aspect | lpq | lpstat -o |
|---|---|---|
| Style | Berkeley | System V |
| Output | Queue with ranks | Job list |
| Shows active | Yes | Yes |
| Shows printer status | Yes | Via -p |
| Job IDs | Yes | Yes |
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:
| Option | Purpose |
|---|---|
-P PRINTER | Specify the printer |
-U USER | Specify the user |
-h SERVER | Specify 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:
| Command | Effect |
|---|---|
lprm | Cancel the current job |
lprm - | Cancel all your jobs |
lprm 345 | Cancel job 345 |
lprm -P canon 345 | Cancel 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:
| Aspect | lprm | cancel |
|---|---|---|
| Style | Berkeley | System V |
| By ID | lprm 345 | cancel 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
| Command | Purpose |
|---|---|
lpstat -a | Show accepting state |
lpstat -p | Show all printers |
lpstat -d | Show default printer |
lpstat -s | Status summary |
lpstat -v | Show devices |
lpstat -o | Show all jobs |
lpstat -r | Scheduler status |
lpstat -t | Full status |
lpstat -l | Verbose |
lpq
| Command | Purpose |
|---|---|
lpq | Queue for default printer |
lpq -P PRN | Queue for specific printer |
lpq -a | Queue for all printers |
lpq -l | Verbose output |
lpq -U USER | Jobs for a user |
lpq +N | Refresh every N seconds |
lprm
| Command | Purpose |
|---|---|
lprm | Cancel current job |
lprm - | Cancel all your jobs |
lprm JOB | Cancel job by ID |
lprm -P PRN JOB | Cancel 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)
| Command | Purpose |
|---|---|
cancel JOB | Cancel job by ID |
cancel PRN-JOB | Cancel with printer |
cancel -a PRN | Cancel all on printer |
cancel -a | Cancel all jobs |
Printer Status Meanings
| Status | Meaning |
|---|---|
idle | No active job |
printing | Currently printing |
disabled | Not accepting jobs |
accepting requests | Taking jobs |
scheduler is running | CUPS 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
| Pitfall | Problem | Solution |
|---|---|---|
| CUPS not running | Nothing works | sudo systemctl start cups |
| Printer disabled | Jobs queue forever | cupsenable PRN |
| Wrong job ID | Can’t cancel | Check lpq first |
lprm - | Cancels all your jobs | Use specific IDs |
No -P | Wrong printer | Specify explicitly |
| Stale jobs | Queue stuck | cancel -a PRN |
| Permission denied | Can’t cancel others | Use sudo |
| lpstat empty | No printers configured | lpadmin 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
| Command | Purpose | Example |
|---|---|---|
lpstat -a | Accepting state | lpstat -a |
lpstat -p | All printers | lpstat -p |
lpstat -d | Default printer | lpstat -d |
lpstat -s | Status summary | lpstat -s |
lpstat -v | Show devices | lpstat -v |
lpstat -o | All jobs | lpstat -o |
lpstat -r | Scheduler status | lpstat -r |
lpstat -t | Full status | lpstat -t |
lpq | Default queue | lpq |
lpq -P PRN | Specific printer queue | lpq -P canon |
lpq -a | All queues | lpq -a |
lpq -l | Verbose queue | lpq -l -P canon |
lpq -U USER | Jobs for a user | lpq -U kronos |
lprm JOB | Cancel job | lprm 345 |
lprm -P PRN JOB | Cancel on printer | lprm -P canon 345 |
lprm -P PRN - | Cancel all on printer | lprm -P canon - |
lprm - | Cancel all your jobs | lprm - |
cancel JOB | Cancel (SysV) | cancel 345 |
cancel -a PRN | Cancel all (SysV) | cancel -a canon |
Key takeaways:
lpstattells you about printers โ-aaccepting,-pall,-ddefault,-ssummary,-tfulllpqshows the queue โ use-Pfor a specific printer,-lfor verbose,-afor alllprmremoves jobs โ by ID, by printer, or all with-cancelis the System V equivalent โcancel JOBorcancel -a PRN- Always run
lpstat -afirst to see what printers exist - Always run
lpqbefore cancelling โ get the job ID right - Use
lpstat -rto check if CUPS is running when nothing prints - Use
-Pto be explicit when multiple printers exist lprm -cancels all your jobs;lprm -a -(as root) cancels everyone’scancel -a PRNis 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!