Software & AppsOperating SystemLinux

How To List Available Printers from Terminal in Ubuntu?

Ubuntu 2

In this article, we will explore how to list all available printers from the terminal in Ubuntu. This can be particularly useful if you’re a system administrator or a developer who frequently interacts with printers.

Quick Answer

To list available printers from the terminal in Ubuntu, you can use the lpstat -p command to display the printer names, or lpstat -p | awk '{print }' | xargs -n1 lpq -P to show both the printer names and their print queues. To view detailed information about all available printers, use lpstat -t. To list all printers on the local network, you can use lpstat -e or lpstat -l -e.

Introduction to Terminal Commands for Printers

In Ubuntu, we use the lpstat command to interact with the printer. This command is part of the Common Unix Printing System (CUPS) and provides information about the current printer status.

Listing Printer Names

To list only the printer names, use the following command:

lpstat -p | awk '{print $2}'

Here, lpstat -p lists the status of all printers. The output is piped (|) to the awk command which prints only the second field ({print $2}) from each line of the output. This field corresponds to the printer names.

Listing Printer Names and Their Print Queues

If you want to see both the printer names and their print queues, you can use the following command:

lpstat -p | awk '{print $2}' | xargs -n1 lpq -P

In this command, xargs -n1 takes the printer names one by one and passes them as arguments to lpq -P, which displays the print queue for each printer.

Listing Detailed Information About Printers

To see more detailed information about all available printers, you can use the -t option with lpstat:

lpstat -t

This command provides detailed information about each printer, including the scheduler information, default printer, printer addresses, enabled status with timestamps, accepting jobs status with timestamps, and if a printer is currently printing.

Listing All Available Printers on the Local Network

The lpstat -p command and its variations will only list local (often called permanent) printers. To list all available printers on the local network, you can use lpstat -e or lpstat -l -e:

lpstat -e

or

lpstat -l -e

These commands will list all printers that are discoverable on the local network.

Conclusion

The terminal in Ubuntu offers powerful tools for managing and interacting with printers. By understanding and using commands like lpstat, you can quickly list and get detailed information about all available printers. Whether you’re a system administrator or a developer, these commands can help you streamline your workflow and increase your productivity.

For more information about the lpstat command and its options, you can check the man page or use the man lpstat command in the terminal.

How can I list all available printers from the terminal in Ubuntu?

To list all available printers from the terminal in Ubuntu, you can use the lpstat -p command. This command will display the status of all printers installed on your system.

How can I list only the printer names?

To list only the printer names, you can use the command lpstat -p | awk '{print $2}'. This command will extract the second field (printer names) from the output of lpstat -p using the awk command.

How can I list both the printer names and their print queues?

To list both the printer names and their print queues, you can use the command lpstat -p | awk '{print $2}' | xargs -n1 lpq -P. This command will pass each printer name to the lpq -P command, which will display the print queue for each printer.

How can I get more detailed information about all available printers?

To get more detailed information about all available printers, you can use the lpstat -t command. This command will provide detailed information about each printer, including scheduler information, default printer, printer addresses, enabled status, accepting jobs status, and current print status.

Can I list all available printers on the local network?

Yes, you can list all available printers on the local network using the lpstat -e or lpstat -l -e command. These commands will list all printers that are discoverable on the local network.

Leave a Comment

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