PRINTERS AND LINUX TERMINAL




PRINTERS AND LINUX TERMINAL

This a down and dirty cheat sheet on how to work with printqueues in linux terminal…

If I am missing anything please let me know and I will add it…

Lets assume your linux system uses CUPS if so try searching for your answer in the following link.. http://localhost:631 if that does not work then check for a solution below

1.  Lets list all printers via terminal

lpstat -p -d

2.  Lets change the default printer via terminal

lpoptions -d printer-name

3.  lets display printers accepting print jobs

lpstat -a

4.  to display all active print jobs

lpstat -o

5.  lets display the status of all print queues

lpstat -t

6.  lets display status of default print queue

restart a stopped print queue

7.  cupsenable (printer name)

To cancel a print job :

8.  List all jobs:

lpq
Rank Owner/ID Class Job Files Size Time
active bob A 11 zarma.txt 8000 10:12:10

9.  Delete the job by it’s id, which is 11 here:

lprm 11

You must be root to delete jobs that you don’t have initiated.

If the printer is not the default printer, add the -P option, e.g.

lpq -P crust
lprm -P crust …

10.  to cancel all print jobs
lpq

This will list all your jobs sent to the printer.

BJC-250 is ready
Rank Owner Job File(s) Total Size
1st ggarron 248 (stdin) 0 bytes
2nd ggarron 249 (stdin) 0 bytes

Now if you want to stop jobs, you can use the cancel command.

You can cancel only jobs owned by you, or by an specified user (provided that you have the rights to do it).

cancel -u user

This will cancel all jobs belonging to a certain user, but, if you want to cancel all jobs, no matter who owns them use this command.

cancel -a

12.  To resume last print job
To resume a job from command line I can call lpq which gives me the job number for example 211 and then lp -i 211 -H resume.

13.  RELEASE PRINT JOB FROM PRINTQUEUE
cupsenable –release $print_queue should push all held jobs out to the printer (assuming it’s still accepting jobs). If the job got held because the printer is marked offline, you may need to cupsenable $print_queue and cupsaccept $print_queue (or in one step lpadmin -E $print_queue), also.

13a.  Moving all print jobs from one print queue to another

Suppose mySamsung is out of service for whatever reason. Then, you need to move all print jobs from mySamsung to myPrinter.

$ sudo lpmove mySamsung myHP

13b. Moving individual jobs from one print queue to another
First, you should find out the print job number. Run the familiar lpq command.

$ lpq -P mySamsung
mySamsung is ready and printing
Rank Owner Job File(s) Total Size
active peter 706 (i) 100352 bytes
1st peter 707 MoviesReview 228352 bytes
$

Say job 707 is the one you want to move to the other printer.

The Linux command to do the actual migration is lpmove. Note that you need to run the command as root.

$ sudo lpmove mySamsung-707 myHP
$ lpq -P myHP
myHP is ready
Rank Owner Job File(s) Total Size
active peter 707 MoviesReview 228352 bytes

Note how I specified the job number to lpmove. The format is the printer name(mySamsung) and a dash(-), followed by the job number (707).

14.  VARIOUS OTHER LPQ AND LPRM COMMANDS

lpq

lpc status printername
Show the status of all the named printer. The printername can be replaced with the keyword all to view the status of all local printers.

lpc disable printername
Turns of the print queue. It prevents new printer jobs from entering the print queue. The printername can be replaced with the keyword all to apply to all local printer queues.

lpc enable printername
Allows new jobs to be added to the print queues. The printername can be replaced with the keyword all to apply to all local printer queues.

lpc stop printername
Stops the spooling daemon after the current job has completed. It then disables printing to that printer. The printername can be replaced with the keyword all to view the status of all local printers.

lpc start printername
Enables printing starting a spooling daemon for the printer. The printername can be replaced with the keyword all to view the status of all local printers.

lprm -P printqueue jobid
Remove requests from the specified queue.

lprm -
If requested by a user it will remove all jobs from that user. If specified by a superuser it will delete all requests on that print queue.

lprm -a
Delete all your jobs on all printers

lprm -a all
Delete all jobs on all printers from all users (superuser only).

Related External Links

This entry was posted in Network and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>