To check the status of the print spooler and all printers, using the CUPS print service
lpstat -t
To check for queued print jobs, using the CUPS print server
lpstat -o
To just check one print queue
lpstat -o PR01
Which, if there is a queued print job, should return something like this
PR01-12345
To see the entries for the print job in the CUPS error log, if the CUPS log level is set to debug
grep 12345 /var/log/cups/error_log
Note: the CUPS error log is frequently rotated. It is possible recent print jobs might be in logs named error_log.0, error_log.1 and so on
To move the job to PR02
lpmove PR01-12345 PR02
To save a copy of the job
cd /var/spool/cups
ls -l d*12345*
Which might return something like this
-rw-r----- 1 root lp 1970 Dec 8 08:56 d12345-001
mkdir save
cp d12345-001 save
To cancel the job
cancel PR01-12345
To cancel the currently printing job, regardless of job id
cancel PR01
To cancel all jobs queued for PR01
cupsdisable -c PR01
cupsenable PR01
accept PR01
To resend the saved job
lpr -PPR01 /var/spool/cups/d12345-001
To check the setup of a CUPS printer, run this
lpstat -v PR01
Which should return something like this
device for PR01: socket://192.168.1.2:9100
That means PR01 is a network printer, set up for Jetdirect style raw socket connections, on ip address 192.168.1.2
The device setup for that same type of printer might also look like this
device for PR01: socket://PR01:9100
In this case, you would need to look for the PR01 hostname in the /etc/hosts file or in dns to determine the ip address.
Another common result might look like this
device for SM01: smb://DOMAIN/COMPUTER/laserjet
Which means it is a Samba printer, and the cups server needs to connect to a computer to access it. For security reasons, lpstat does not display the login credentials for samba printers. To get the login credentials, you could do something like this
grep COMPUTER /etc/cups/printers.conf
Which should return something like this
DeviceURI smb://username:password@DOMAIN/COMPUTER/laserjet
Some network printers are set up in the LPD style. Those would like something like this
device for PR01: lpd://PR01/raw
In the above, the printer is named PR01 and a host name of PR01 is also used in the /etc/hosts file to connect. The ‘raw’ at the end means the port name is raw. Different print servers may use different port names, but raw and text are common, and may be used to tell the print server how to process the job. An LPD printer, like a Jetdirect printer, might be set up with an ip address rather than a hostname
The following steps may be effective for getting CUPS printers going in many cases
First
Have the user turn the power switch off on the printer
Have the user unplug the printer’s electric cord
Wait 30 seconds
Have the user plug the electric cord back in
Have the user switch on the printer
Have the user confirm that the printer has paper
Have the user check for error messages on the printer console
See if anything prints after that
Second
Check the print queue on the server for stalled jobs
lpstat -o PR01
Restart the print queue
cupsdisable PR01
cupsenable PR01
accept PR01
Run lpstat -o PR01 again to see if the jobs printed
Third
Check connectivity
lpstat -v PR01
Which should return something like
device for PR01: socket://PR01:9100
Then do
ping PR01
And see if it responds. If not, find out if the ip address has changed. Note in the above, PR01 is an /etc/hosts hostname. That field could often be an ip address, as well.
Fourth
Restart the print server
/sbin/service cups restart
Network changes and problems commonly affect printing
Here are a few examples of how to check whether the server is able to connect to the printers
Jetdirect (socket) printers
lpstat -v PR01
device for PR01: socket://192.168.1.2:9100
nmap -sS -p9100-9100 192.168.1.2
nmap, which is a port scanner, should return something like this if successful
Starting Nmap 5.51 ( http://nmap.org ) at 2014-12-10 16:32 CST
Nmap scan report for PR01 (192.168.1.2)
Host is up (0.17s latency).
PORT STATE SERVICE
9100/tcp open jetdirect
Nmap done: 1 IP address (1 host up) scanned in 0.58 seconds
Or something like this if not
Starting Nmap 5.51 ( http://nmap.org ) at 2014-12-10 16:33 CST
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.18 seconds
Or possibly this
Starting Nmap 5.51 ( http://nmap.org ) at 2014-12-10 16:32 CST
Nmap scan report for PR01 (192.168.1.2)
Host is up (0.17s latency).
PORT STATE SERVICE
9100/tcp filtered jetdirect
Nmap done: 1 IP address (1 host up) scanned in 0.58 seconds
If nmap is unavailable, you can do the poor man’s portscan
[root@svr ~]# telnet 192.168.1.2 9100
Trying 192.168.1.2...
Connected to 192.168.1.2
Escape character is ‘^]’
^]
telnet> quit
Connection closed
If 9100 is open, it will connect and sit there. If not, telnet will just say trying, and eventually time out. To close the connection if it does connect and sit there, hit CTL+], then quit at the prompt
LPD printers
Use the same procedures as for Jetdirect, but substitute the Jetdirect 9100 port with the LPD port, 515. For example
[root@svr ~]# nmap -sS -p515-515 192.168.1.2
Starting Nmap 5.51 ( http://nmap.org ) at 2014-12-10 16:41 CST
Nmap scan report for PR01 (192.168.1.2)
Host is up (0.090s latency).
PORT STATE SERVICE
515/tcp open printer
Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds
Samba printers
Samba printers require that the server is able to authenticate to the workstation the printer is attached to. For this reason, simply checking for open ports on the computer is not a valid connectivity test for samba printers. It is better to log in to the computer, the same way the print queue is set up. For example
lpstat -v SM01
device for SM01: smb://DOMAIN/COMPUTER/laserjet
grep COMPUTER /etc/cups/printers.conf
DeviceURI smb://username:password@DOMAIN/COMPUTER/laserjet
smbclient //computer/laserjet -U username
Enter usernames’s password:
If successful, you should get something like
Domain=[DOMAIN] OS=[Windows 7 Professional 7601 Service Pack 1] Server=[Windows 7 Professional 6.1]
smb: \>
If you want to test from that prompt, you could send a text file to the printer. For example
smb: \>print /etc/hosts
But the main thing is, you were able to connect
To close the connection
smb: \>quit
Another way to use smbclient to diagnose problems is to run a share list, which you can do like so
smbclient -L COMPUTER -U username
Enter username’s password:
Domain=[DOMAIN] OS=[Windows 7 Professional 7601 Service Pack 1] Server=[Windows 7 Professional 6.1]
Sharename
|
Type
|
Comment
|
---------
|
---------
|
---------
|
ADMIN$
|
Disk
|
Remote Admin
|
C$
|
Disk
|
Default Share
|
IPC$
|
IPC
|
Remote IPC
|
laserjet
|
Printer
|
HP Laserjet 5
|
Note the share names in the Sharename column. It is common for users to get new computers without their old sharenames set up
If everything seems correct with a samba printer, but the login keeps failing, try this
On the user’s computer, have them find Control Panel. If they have Windows 8 and they don’t see it, they can press the Windows logo key between
ctl and
alt on the keyboard along with the
r key, and enter
control in the box that comes up. If they have Windows 7, the same key combination should work, but it should also be on the Start menu.
Look for
Network and Sharing Center. If they don’t see it, try changing the view option in the upper right of the screen to
small icons. Click it.
Look for
Change advanced sharing settings at the upper left, click it
Scroll down to the bottom of the screen to the
File sharing connections section
Set it to
Enable file sharing for devices that use 40 or 56 bit encryption
Save the changes.
Although Samba does not actually use encryption that weak, that setting often helps Linux and Windows agree on an encryption protocol