LinuxCommandLibrary

lprm

Remove jobs from the print queue

TLDR

Cancel current job on the default printer

$ lprm
copy

Cancel a job of a specific server
$ lprm -h [server] [job_id]
copy

Cancel a job of a specific server in a specific port
$ lprm -h [server]:[port] [job_id]
copy

Cancel multiple jobs with a encrypted connection to the server
$ lprm -E [job_id1 job_id2 ...]
copy

Cancel all jobs
$ lprm -
copy

Cancel the current job of a specific printer or class
$ lprm -P [destination]/[instance]
copy

SYNOPSIS

lprm [ -Pprinter ] [ - ] [ job #... ] [ user ... ]

PARAMETERS

-Pprinter
    Specifies the printer queue from which to remove jobs. If omitted, the default printer is used (usually defined by system configuration or the PRINTER environment variable).

-
    Removes all jobs owned by the current user from the specified or default printer queue. This option is often restricted to the superuser for security reasons on some systems.

job #...
    A space-separated list of one or more job numbers to be removed. Job numbers can be found by inspecting the print queue using the lpq command.

user ...
    A space-separated list of one or more usernames. This removes all jobs belonging to the specified users from the queue. This option typically requires superuser privileges.

DESCRIPTION

lprm is a command-line utility used to remove print jobs that are currently queued for printing on a line printer. It interacts with the printer spooling system, typically lpr/lpd (Line Printer Daemon) or CUPS (Common Unix Printing System) which often emulates lpd functionality.

Users can remove their own jobs by specifying job numbers, or remove all their own jobs from a queue. The superuser can remove any job from any queue, including jobs owned by other users or all jobs from a specific queue. This command is crucial for managing print queues, especially when a print job is stuck, sent incorrectly, or no longer needed, allowing for efficient control over printing resources.

CAVEATS

  • Permissions: Users can only remove their own print jobs unless they have superuser (root) privileges. Attempting to remove another user's job without proper permissions will result in an error.
  • Job in Progress: lprm cannot stop a job that is already actively being printed by the printer hardware itself. It only removes jobs from the queue before they reach the printer or if they are still being spooled.
  • Spool Directory: The command operates on the spool directory where print jobs are temporarily stored. Issues with this directory's permissions or disk space can affect lprm's operation.
  • Network Printers: For network printers, the job might be spooled on a remote server. lprm needs to communicate with that server, and network issues or server misconfigurations can prevent it from working correctly.

DEFAULT BEHAVIOR

If no arguments are provided to lprm (i.e., no printer, no job number, no user, and not the '-' option), it will not remove any jobs. Instead, it will typically display a usage message indicating the correct syntax for the command, requiring at least one valid argument to perform an action.

ENVIRONMENT VARIABLES

The PRINTER environment variable can be set by the user to specify a default printer. When this variable is set, lprm will operate on that printer queue by default, overriding the system's default printer definition and eliminating the need to use the -P option explicitly for every command.

HISTORY

lprm is an integral part of the original BSD printing system, which was widely adopted across Unix-like operating systems. It was specifically designed to work with the lpd (Line Printer Daemon) protocol for managing networked printers. While many modern Linux distributions now use CUPS (Common Unix Printing System) as their default printing backend, lprm is commonly provided for backward compatibility. CUPS emulates the behavior of the traditional BSD printing commands, ensuring that existing scripts and user workflows familiar with lprm continue to function seamlessly. Its fundamental functionality has remained largely consistent since its inception, reflecting a core requirement for managing print queues efficiently.

SEE ALSO

lpr(1), lpq(1), lpc(8), lpstat(1), cancel(1)

Copied to clipboard