Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
cancel
Showing results for 
Search instead for 
Did you mean: 

Printing with Linux

John R Sherman
Occasional Advisor

Printing with Linux

Can anyone give me info on print commands under Linux (Red Hat)? I'm trying to print bar codes and the PCL commands are printing instead of bar codes (HP1320 printer). Are there any Linux commands that will send files to the printer?
Thanks,
John Sherman
4 REPLIES
Matti_Kurkela
Honored Contributor

Re: Printing with Linux

Which version of RedHat? And RedHat may have several printing engines available in each distribution: are you using CUPS, LPRng or something else?

How is the printer connected? If it uses a parallel or USB connection, you can use basic commands like "cat" to bypass the print spooler and send files directly to the printer:

cat filename > /dev/lp0
cat filename > /dev/usb/lp0

If you're using a JetDirect connection, you might use the "rlpr" command or dump the data to printer's network port (TCP/9100) using netcat (nc) or even "telnet printername 9100 < filename".

Bypassing the print spooler on a parallel- or USB-connected printer usually requires more permissions than the normal user has. It's also not recommended when multiple users may be trying to print simultaneously.

Regardless of which print spooling engine you're using, the normal printing command is generally either "lp" or "lpr". CUPS uses "lp" natively, but it can provide the "lpr" command too if you have something that requires BSD-style printing commands.

Both styles of commands can have various options to bypass automatic format detection and send the file to the printer explicitly as-is. Usually the options are "lp -o raw" or "lpr -l".

MK
MK
John R Sherman
Occasional Advisor

Re: Printing with Linux

Hi Matti,
Version of Linux... I'm really not a Linux expert. What command will give me that (we're not using the GUI). I just tried using lp to print the raw file, but it didn't work (the bar code didn't print).
Matti_Kurkela
Honored Contributor

Re: Printing with Linux

If it's a RedHat Linux, then "cat /etc/redhat-release" should display the version. If this works, it's either RedHat Linux 9 or older (=way out of support) or one of the RedHat Enterprise Linux distributions.

If it's one of the RedHat's free Fedora distributions, then examine /etc/fedora-release.

If the lp command caused at least *something* to print, the output of "lpstat -v" might tell us more about how your printer is connected. "lpstat -l -p" and "lpoptions" output listings might also help.

MK
MK
skt_skt
Honored Contributor

Re: Printing with Linux

"printconf-tui"

# whereis printconf-tui
printconf-tui: /usr/sbin/printconf-tui