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]
If you encounter the below error while running the lpq command:
lpq: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install lprng |
Ubuntu | apt-get install gnuspool |
Alpine | apk add cups |
Arch Linux | pacman -S cups |
Kali Linux | apt-get install lprng |
Fedora | dnf install cups |
Raspbian | apt-get install gnuspool |
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.