Linux lpstat command
On Unix-like operating systems, the lpstat command lists the status of LP print services.
Description
lpstat displays status information about the current classes, jobs, and printers. When run with no arguments, lpstat lists jobs queued by the current user.
lpstat is now part of the CUPS (Common Unix Printing System). You may need to install CUPS before using lpstat, and related tools such as lpr.
Installing CUPS
If you're operating Debian, or a Debian-derived Linux system like Ubuntu that uses the APT package managements system, you can install them by running the following command:
sudo apt-get update && sudo apt-get install cups cups-client lpr
This command will install the Common Unix Printing System on your system. You should now be able to set up CUPS by directing any web browser to the address: http://localhost:631
Doing so opens a web-based CUPS configuration screen, which should look something like this:
Then, from the command line, add your user to the group lpadmin with the command:
sudo adduser <yourusername> lpadmin
This command adds you to the group of users allowed to administer printers on your system.
You should now be able to check the status of your printers and your print jobs using lpstat.
Syntax
lpstat [ -E ] [ -H ] [ -U username ] [ -h hostname[:port] ] [ -l ] [ -W which-jobs ] [ -a [ destination(s) ] ] [ -c [ class(es) ] ] [ -d ] [ -o [ destination(s) ] ] [ -p [ printer(s) ] ] [ -r ] [ -R ] [ -s ] [ -t ] [ -u [ user(s) ] ] [ -v [ printer(s) ] ]
Options
-E | Forces encryption when connecting to the server. |
-H | Shows the server hostname and port. |
-R | Shows the ranking of print jobs. |
-U username | Specifies an alternate username; runs lpstat as if you were user username. This option requires superuser privileges. |
-W which-jobs | Specifies which jobs to show, completed or not-completed (the default). This option must appear before the -o option or any printer names, otherwise the default (not-completed) value will be used in the request to the scheduler. |
-a [printer(s)] | Shows the accepting state of printer queues. If no printers are specified then all printers are listed. |
-c [class(es)] | Shows the printer classes and the printers that belong to them. If no classes are specified then all classes are listed. |
-d | Shows the current default destination. |
-h server[:port] | Specifies an alternate server. |
-l | Shows a long listing of printers, classes, or jobs. |
-o [destination(s)] | Shows the jobs queue on the specified destinations. If no destinations are specified all jobs are shown. |
-p [printer(s)] | Shows the printers and whether or not they are enabled for printing. If no printers are specified then all printers are listed. |
-r | Shows whether the CUPS server is running. |
-s | Shows a status summary, including the default destination, a list of classes and their member printers, and a list of printers and their associated devices. This option is equivalent to using the "-d", "-c", and "-v" options. |
-t | Shows all status information. This option is equivalent to using the "-r", "-d", "-c", "-v", "-a", "-p", and "-o" options. |
-u [user(s)] | Shows a list of print jobs queued by the specified users. If no users are specified, lists the jobs queued by the current user. |
-v [printer(s)] | Shows the printers and the attached devices. If no printers are specified then all printers are listed. |
Examples
lpstat -t
Display all printer information. Output resembles the following:
scheduler is running system default destination: PDF device for Lexmark_Pro700_Series: usb://Lexmark/Pro700%20Series?serial=90T7099T1914144&interface=1 device for PDF: cups-pdf:/ Lexmark_Pro700_Series accepting requests since Mon 18 Aug 2014 03:46:06 PM EDT PDF accepting requests since Sun 17 Aug 2014 09:51:41 PM EDT printer Lexmark_Pro700_Series disabled since Mon 18 Aug 2014 03:46:06 PM EDT - Unplugged or turned off printer PDF is idle. enabled since Sun 17 Aug 2014 09:51:41 PM EDT
lpstat -p
Display all installed printers. Output resembles the following:
printer Lexmark_Pro700_Series disabled since Mon 18 Aug 2014 03:46:06 PM EDT - Unplugged or turned off printer PDF is idle. enabled since Sun 17 Aug 2014 09:51:41 PM EDT
lpstat -a
Display only those printers that are currently accepting print requests. Output resembles the following:
Lexmark_Pro700_Series accepting requests since Mon 18 Aug 2014 03:46:06 PM EDT PDF accepting requests since Sun 17 Aug 2014 09:51:41 PM EDT
Note that printers that are currently powered off still accepts requests; these requests remain in the queue until the device is powered on, or the request is removed with lprm.
lpstat -d
Displays which printer is currently the default. Output resembles the following:
system default destination: Lexmark_Pro700_Series
lpstat -o
Display all active print jobs. Output resembles the following:
Rank Owner Job Files Total Size 1st hope 1 budget.txt 2315 bytes 2nd hope 2 /home/hope/docs/userlist.txt 5452 bytes 3rd hope 4 (standard input) 52954 bytes 4th hope 5 /tmp/vroAdm2/1 5827 bytes
Related commands
cancel — Cancels a print job under the System V operating system.
lp — Print a file on the System V operating system.
lpq — List the status of available printers.
lpr — Submit print requests.
lprm — Remove requests from the print queue.