• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lpq Command Examples in Linux

by admin

The lpq command shows the status of the printer queue. By default, it will report each print job’s rank in the queue, who owns the job, the job number, the files in the job, and the size of the job. You can also have the report update every number of seconds that you specify with the +interval option, until the queue is empty. If you don’t specify the printer to monitor, the lpq command will monitor the default printer.

Syntax

The syntax of the lpq command is:

# lpq [options]

lpq Command Examples

1. Examine active jobs:

$ lpq
lp is ready and printing
Rank   Owner      Job  Files                 Total Size
active root       193  filter                9443 bytes
1st    root       194  resume.txt            11024 bytes
2nd    root       196  (standard input)      18998 bytes

Here, filter is currently being printed. resume.txt is up next, followed by the 18,998 bytes of data piped into lpr’s standard input.

2. Examine those same jobs using the long format:

$ lpq -l
lp is ready and printing
root: active                             [job 193AsJRzIt]
        filter                           9443 bytes
root: 1st                                [job 194AMj9lo9]
        resume.txt                       11024 bytes
root: 2nd                                [job 196A6rUGu5]
        (standard input)                 18998 bytes

3. Examine queue lp, which turns out to be empty:

$ lpq -Plp
no entries

4. Examine jobs owned by geek:

$ lpq geek
Rank   Owner      Job  Files                 Total Size
7th    geek     202  .bash_history         1263 bytes
9th    geek     204  .bash_profile         5676 bytes

Conclusion

The lpq command can be used to check the status of jobs that are waiting in the print queue. If it is called without any arguments, lpq will report the status of all jobs currently in the queue for the default printer. If the PRINTER environment variable is set, that printer is considered to be the default printer. If the PRINTER environment variable is not set, the printer that is aliased to lp in /etc/printcap will be used as the default.
Using the job numbers reported by lpq, any user may remove her own print jobs from the queue, or the superuser may remove any job.

Filed Under: Linux

Some more articles you might also be interested in …

  1. atrm Command Examples in Linux
  2. ddcutil: command not found
  3. lscpu: command not found
  4. konsole Command Examples in Linux
  5. CentOS / RHEL : How to find Logical volumes (LVs) contained in Physical Volume (PVs) in LVM
  6. Cron Script does not Execute as Expected from crontab – Troubleshoot
  7. ssh-copy-id: command not found
  8. Understanding Ksplice Effective Kernel Version
  9. Understanding MySQL Pluggable Authentication
  10. How to use perf tool for tracing similar to dtrace

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright