- Print from command line linux
- Печать из командной строки Linux
- Вывод параметров принтера
- Полезные команды
- Двусторонняя печать
- Печать в ландшафтном режиме
- Printing from the Linux Command Line
- Need to print shipping labels on your site?
- Printing from the Linux command line
- There’s a lot more to printing from the Linux command line than the lp command. Check out some of the many available options.
- Displaying printer settings
- Useful commands
- Two-sided printing
- Printing in landscape mode
- Print from command line linux
Print from command line linux
Printing Commands in Linux or Debain Linux
Linux includes a number of command line tools for administering printing. These commands are useful on networks, or for troubleshooting and managing printing on any system.
Each printer on a Linux system has its own spool or queue in the /var /spool/lpd directory. This spool uses the short name of the printer, which is created when the printer is first configured. When a file is printed, it becomes a job in the spool. Each job is stored in a spool until it is printed.
Printing tools generally start with lp (short for «line printer»). If you are familiar with other Linux commands, you can usually make a good guess at what the rest of the command should be. For example, lprm removes a print job from the spool
You can use the following tools for managing printing
lpq : Checks the status of print jobs.
lprm : Removes a print job from a spool.
lpstat : Reads the status of a spool.
Checking the Status of Print Jobs
lpq options user
The command’s name comes from the fact that a spool is sometimes called a «queue.»
The lpq Command (Print Jobs) Options
-l — Prints information for each file in the printer queue.
number — Checks the status of a job number.
-P printer — Sets the printer that a job should Use.
If you want to know more options check lpq man page
Sends requests to a line printer
lp options files
If you want to know more options check lp man page
Removing Jobs From a Printer Spool
lprm options job user
The command’s name comes from the fact that it removes (rm) a job from a line printer (lp).
Only the root user can remove a job sent by another user.
Regular users can remove their own print jobs.
Use lpstat to find job numbers.
The lprm Command (Remove Print Jobs) Options
-P printer — Sets the printer to Use.
— user — Removes all jobs sent by the user specified.
If you want to know more options check lprm man page
Reading the Status of a Printer Spool
lpstat -t options
If you want to know more options check lpstat man page
Printing From the Command Line
lpr options files
The lpr Command (Print) Options
-P printer — Selects the printer to Use.
-s — This option saves time and disk space for large files, but may cause printing to be slower.
If you want to know more options check lpr man page
Источник
Печать из командной строки Linux
Оригинал: Printing from the Linux command line
Автор: Sandra Henry-Stocker
Дата публикации: 20 марта 2019 года
Перевод: А. Кривошей
Дата перевода: апрель 2016 г.
Печать из командной строки Linux очень проста. Вы используете команду lp, чтобы запросить печать, и lpq, чтобы увидеть, какие задания на печать находятся в очереди, но все становится немного сложнее, когда вы хотите печатать на двух сторонах листа или в портретном режиме. И есть много других вещей, которые вы можете захотеть сделать — например, распечатать несколько копий документа или отменить задание на печать. Давайте проверим некоторые опции, чтобы, когда вы печатаете из командной строки, ваши распечатки выглядели именно так, как вы хотите.
Вывод параметров принтера
Чтобы просмотреть настройки принтера из командной строки, используйте команду lpoptions. Вывод должен выглядеть примерно так:
Этот вывод, вероятно, будет немного более дружественным к человеку, если вы превратите его пробелы в возврат каретки. Обратите внимание, сколько настроек указано в списке.
ПРИМЕЧАНИЕ. В приведенном ниже выводе некоторые строки были повторно связаны, чтобы сделать этот вывод более читабельным.
С опцией -v команда lpinfo выведет список драйверов и связанной с ними информации.
Команда lpoptions покажет настройки вашего принтера по умолчанию. Используйте параметр -p, чтобы указать один из нескольких доступных принтеров.
Команда lpstat -p отображает состояние принтера, а команда lpstat -p -d также выводит список доступных принтеров.
Полезные команды
Чтобы распечатать документ на принтере по умолчанию, просто используйте команду lp, а затем имя файла, который вы хотите распечатать. Если имя файла содержит пробелы (что редко встречается в системах Linux), либо поместите имя в кавычки, либо начните вводить имя файла и нажмите клавишу табуляции, чтобы вызвать завершение файла (как показано во втором примере ниже).
Команда lpq отображает очередь печати.
Команда lp с опцией -n позволяет вам указать количество копий, которое вы хотите напечатать.
Чтобы отменить задание на печать, вы можете использовать команду cancel или lprm. Если вы не будете действовать быстро, то можете увидеть это:
Двусторонняя печать
Чтобы печатать в двухстороннем режиме, вы можете ввести команду lp с параметром sides, в котором указано, как печатать на обеих сторонах листа, и вид переплета (сбоку или сверху). Этот параметр представляет обычный способ, при которым вы получите двусторонний документ в портретном режиме.
Если вы хотите, чтобы все ваши документы печатались в двухстороннем режиме, вы можете изменить настройки lp для sides с помощью команды lpoptions.
Чтобы вернуться к односторонней печати, вы должны использовать такую команду:
Печать в ландшафтном режиме
Для печати в ландшафтном режиме вы должны использовать параметр landscape с командой lp.
Система печати, используемая в системах Linux, — это основанная на стандартах система печати с открытым исходным кодом, называемая CUPS, первоначально обозначавшая Common Unix Printing System. Она позволяет компьютеру выступать в качестве сервера печати.
Источник
Printing from the Linux Command Line
So you have your printer set up with CUPS and you can now print. Ever want to print from the command line? Ever need your bash script to print out system status reports or simply want to print out entire directory of pdfs all in one shot without having to open each pdf individually? Than this quick tip is for you.
After you can successfully print and have your default printer setup in Linux. Open up the terminal. The command to print in Linux is ‘lpr’.
From here you can use the command just like you would any other Linux command. For example if you wanted to print out all pdf’s in a directory you would simply use the following command.
I am sure you can find all kinds of ways to use this. Even ways to torment your co-workers by setting up a cron job lpr print that will print random sayings with ‘fortune’.
#!/bin/bash COUNTER=0 while [ $COUNTER -lt 10 ]; do sleep 10m fortune | lpr let COUNTER=COUNTER+1 done
To use this script open your favorite text editor and create a file with any name you want
Then paste the code and save the file.
Then make the file executable by changing the permissions on your file to 755.
chmod 755 randomFortunePrint
Run your program with:
Here is what mine said.
Q: Why did the astrophysicist order three hamburgers? A: Because he was hungry.
I am sure you can find more constructive ways to use this. 🙂 Please let me know what kinds of things you guys come up with.
Need to print shipping labels on your site?
Checkout my product RocketShipIt for simple easy-to-use developer tools for UPS™ FedEx™ USPS™ and more.
Источник
Printing from the Linux command line
There’s a lot more to printing from the Linux command line than the lp command. Check out some of the many available options.
Printing from the Linux command line is easy. You use the lp command to request a print, and lpq to see what print jobs are in the queue, but things get a little more complicated when you want to print double-sided or use portrait mode. And there are lots of other things you might want to do — such as printing multiple copies of a document or canceling a print job. Let’s check out some options for getting your printouts to look just the way you want them to when you’re printing from the command line.
Displaying printer settings
To view your printer settings from the command line, use the lpoptions command. The output should look something like this:
This output is likely to be a little more human-friendly if you turn its blanks into carriage returns. Notice how many settings are listed.
NOTE: In the output below, some lines have been reconnected to make this output more readable.
With the -v option, the lpinfo command will list drivers and related information.
The lpoptions command will show the settings of your default printer. Use the -p option to specify one of a number of available printers.
The lpstat -p command displays the status of a printer while lpstat -p -d also lists available printers.
Useful commands
To print a document on the default printer, just use the lp command followed by the name of the file you want to print. If the filename includes blanks (rare on Linux systems), either put the name in quotes or start entering the file name and press the tab key to invoke file completion (as shown in the second example below).
The lpq command displays the print queue.
With the -n option, the lp command allows you to specify the number of copies of a printout you want.
To cancel a print job, you can use the cancel or lprm command. If you don’t act quickly, you might see this:
Two-sided printing
To print in two-sided mode, you can issue your lp command with a sides option that says both to print on both sides of the paper and which edge to turn the paper on. This setting represents the normal way that you would expect two-sided portrait documents to look.
If you want all of your documents to print in two-side mode, you can change your lp settings by using the lpoptions command to change the setting for sides.
To revert to single-sided printing, you would use a command like this one:
Printing in landscape mode
To print in landscape mode, you would use the landscape option with the lp command.
The print system used on Linux systems is the standards-based, open source printing system called CUPS, originally standing for Common Unix Printing System. It allows a computer to act as a print server.
Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as «USL» (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she’s chasing the bears away from her bird feeders.
Источник
Print from command line linux
Printing from within an application is very easy, selecting the Print option from the menu.
From the command line, use the lp or lpr command.
These commands can read from a pipe, so you can print the output of commands using
There are many options available to tune the page layout, the number of copies, the printer that you want to print to if you have more than one available, paper size, one-side or double-sided printing if your printer supports this feature, margins and so on. Read the man pages for a complete overview.
Once the file is accepted in the print queue, an identification number for the print job is assigned:
> lp /etc/profile request id is blob-253 (1 file(s))
To view (query) the print queue, use the lpq or lpstat command. When entered without arguments, it displays the contents of the default print queue.
> lpq blob is ready and printing Rank Owner Job File(s) Total Size active davy 253 profile 1024 bytes davy:
> lpstat blob-253 davy 1024 Tue 25 Jul 2006 10:20_01 AM CEST
Which is the default printer on a system that has access to multiple printers?
> lpstat -d system default destination: blob
What is the status of my printer(s)?
> lpstat -p printer blob now printing blob-253. enabled since Jan 01 18:01
If you don’t like what you see from the status commands, use lprm or cancel to delete jobs.
In the graphical environment, you may see a popup window telling you that the job has been canceled.
In larger environments, lpc may be used to control multiple printers. See the Info or man pages on each command.
There are many GUI print tools used as a front-end to lp , and most graphical applications have a print function that uses lp . See the built-in Help functions and program specific documentation for more.
Why are there two commands for every task related to printing? |
---|
Printing documentation |
---|