How To Force Your Printer To Work With Linux

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so i just spent one thousand four hundred fifty nine dollars plus tax on this printer and i also spent five hundred seventy nine dollars plus tax on a set of inks for it and if i come over here and check the manufacturer's web page this printer is not supported on linux this is unacceptable in this video we'll discuss the topic of how to force your printer to work with linux you're probably watching this video because your printer isn't working on linux and you want to learn how to force it to before we dive into the details let's get some of the obvious things to try out of the way first the first thing to try is just plug it in and see if it automatically appears as a new printer sometimes the printer will just install and work immediately without having to do any setup the next thing to try is go into your settings and manually add it as a new printer often this will give you at least some basic printer functionality you should also check the manufacturer's web page for linux drivers some manufacturers do officially support linux and if you can get their drivers to install there's a very good chance that they'll work installing the manufacturer's driver can be worth doing even if the auto installed driver works too the manufacturer's driver is likely to offer additional functionality and better reliability while you're at it if you can find the drivers for your printer you should save a backup copy there's a very good chance that you won't be able to download them anywhere in four or five years from now but most likely you'll still have that printer and you'll want to use it if you can't find the driver for your exact model of printer on the manufacturer's page or the default linux printer menu you can try adding your printer as if it was another one in the same series from the same manufacturer with a similar model number for example my printer is an epson p900 but after browsing through some of the ppd files that were installed when i set up this printer i can see that it mentions a p800 under the hood which is the previous model of this same printer okay so let's say your printer is not supported by the manufacturer and the auto install process doesn't seem to work for you here are a few simple things to consider trying first you should consider testing out every method of connecting to the printer that it supports many printers commonly support usb and ethernet some also let you connect to it wirelessly if you're not interested in messing around with drivers you can just try out each of these methods and hopefully one of them will work for you if it does that might also give you some information about what the root cause of the problem is i can tell you that my printer didn't immediately work with usb but it did work with ethernet this suggested that the root cause of the problem was related to the usb connection another tip that's easy to forget about is that not all usb ports are created equally both the printer and the usb port on your computer will use different versions of the usb protocol it's not unheard of for certain devices to only work in some of the usb ports on your computer now let's talk about additional software that you can try installing if you do some research on printing on linux you'll come up with the term guten print apparently this was formerly called print at the time of creating this video it looks like this page hasn't been updated in two years nevertheless if you want to get more printer drivers you can run this command to install them this works on ubuntu 2004 and in doing some research for this video i also found a whole bunch of other printer driver related packages it looks like there are many different classes of printer drivers available for install it looks like it also might be a good bet to install the printer driver all package but i haven't tried this myself another alternative is a program called turboprint turboprint is not free and it's not open source but given the very frustrating state of printing on linux it's good to see that there's actually someone developing for this platform if you install the gluten print drivers you should be able to just come back in and try adding the printer again if you buy and install turboprint it comes with a separate and dedicated application for adding new printers now if you've reached this point and your printer still doesn't work with linux we're going to have to start our journey out into the wilderness and debug it the goal of the rest of this video won't be to show you how to solve every printer problem but rather to make you aware of the tools that are available to analyze and debug the problem one of the first things that i'd suggest doing is to plug in the printer via usb and run this command this will show you all of the usb devices that linux is able to successfully recognize there's so many names here that it's hard to tell if one of them is actually a printer i find that the fastest way to tell if the printer is being detected or not is to unplug it and rerun lsusb now let's run it again alright do you see any differences here's one that's missing let's plug it back in again and now that it's plugged in again here is that device you can use lsusb to list out a specific bus and device number too with the dash s flag and here's our device again you can also use the dash v flag to see verbose information about this device let's pipe this into less here's some detailed information about this printer without knowing what the problem is it's difficult to know what to look for here but in this case it's reassuring that the kernel detects that this is a printer a common cause of devices not working properly is when they get detected as the wrong type of device if instead of a printer this was classified as a usb storage device or a usb mouse that could be the root of the problem occasionally you may need to use sudo to see all of the information that lsusb provides if the printer shows up in the output of lsusb another thing worth checking is to see if it shows up at this location and here's our printer in my experience a usb printer does not necessarily need to show up at this location in order for it to work properly many people online seem to suggest that when printers show up at this location this is part of the old way of doing things and that it should no longer be relied upon a related topic of discussion is the kernel module usb lp and also the library lib usb these two components have a complex and confusing history some people online seem to suggest that usb lp represents an older way of doing things both of these different pieces of software can potentially be involved in usb communication with printers many people online state that they could only get one or the other to work some people suggested that they needed to blacklist the usb lp module while others suggested that they needed to selectively enable this module to get it to work with only some of their printers some people suggest that these two can have conflicts if you're interested in reading more here's a discussion thread about the usb lp module and here's a discussion thread that suggests that the usb lp module is deprecated i wasn't able to find a more conclusive statement about it being deprecated than this and here's a bug that was filed discussing conflicts between lib usb and usb lp despite all of this usb lp appears to be enabled by default on ubuntu 2004 another location worth checking is this here i can see that my printer is detected and also it's assigned the group lp something else worth checking is to see what cups back ends are installed on your system each of the executables that you see here is a program dedicated toward communicating with printers using a specific protocol you can also use them for searching for printers that communicate using that specific protocol let's see if this detects any usb printers and here you can see information about my printer however according to this documentation cups printer drivers and back ends are deprecated and will no longer be supported in the future having said this i don't know exactly what will replace them i have a feeling that even though these are deprecated they will probably be used long into the future it also says cups back ends are generally not designed to be run by an end user unless you are a developer and know what you are doing please do not run them another command worth running is the lp stat command here is some of the information that it shows about my printers and their configuration you can also run the lpinfo command here is even more information about my printers okay so before we move on we should back up a little bit there are many moving parts to consider when trying to debug printing on your system i'll try to give you a brief introduction to each one of them so you'll at least know what they are and why they might be causing you problems the first and most important is called cups cup stands for common unix printing system if you're new to the concept of printing on linux cups is probably one of the most important things to learn about here are some of the cups related packages on my system as you can see there are a lot of them and i don't even know what all of them do first i'll direct your attention to this one this is actually a web server typically if you browse to localhost port 631 you'll see this interface for interacting with cops here you can find a bunch of documentation about cups and you can also view your printers this can be a bit confusing because it means there are two different interfaces for looking at your printers there's a lot more to say about cups but i'll talk about some of the other components first the next important system component to think about is called udev this is a fairly low level system component that exists on nearly all linux systems the purpose of udev is to forward kernel device events to user space whenever a device is added or removed from the system if you want to learn about udev you should definitely look at the files at this location here we can see a bunch of different udev rules that are installed on my system let's look at the rules in one of the files i won't pretend to know everything about udev rules but i can say a few things about this information this rule is designed to match kernel events that fit a specific pattern when the pattern is matched an action is performed in this case udef performs an action that interacts with a program called system d knowing about systemd is important because if your system uses it it's one of the first processes that runs when your computer boots the purpose of systemd is to manage other processes and services therefore if something related to printing is broken it could be because of a configuration problem related to system d another important program is this one iepp usb xd this program is important because it establishes network-based printer communication over usb i also did some poking around in the source code for this program and found some interesting things in this file here you can see it's doing something related to releasing a usb printer interface and here it's using some kind of spin lock i'm not confident that i know what this code is doing but i do think it's related to some of the printer problems i've had in the past another important program on your system is called app armor this program is important because sometimes it will cause other programs to fail if they don't have the right permissions to do something for example if a user process tries to access system files you'll usually see a bunch of error statements in the log files the log statements will say that app armor denied the program access a common symptom of your program not having the right permissions is that it will just silently fail without telling you anything unless you check the log files dbus is a program for passing messages on your system dbus interacts with cup services so if dbus experiences problems cops may also experience problems the lp command is a program that you can use to print things on the command line the lpr command is also a program that you can use to print things on the command line these two programs have a long and complex history and neither one of them is a complete substitute for the other on modern systems both of these commands are considered to be replaced by cops and they're provided for compatibility with older systems now let's talk about printer drivers generally when people talk about drivers most people think about pre-compiled binaries when it comes to printer drivers things are much more complicated let's take a look at this file for one of my printers ppd stands for postscript printer description in the early days of printing some of the first printers implemented the postscript language therefore it was only natural to use postscript to describe the printer on the computer end the postscript software was proprietary software developed by adobe there is an entire complex history here regarding proprietary licensing requirements for printers that use postscript of course what happened is that many printers came to not use postscript at all however cops attempts to maintain this postscript-based abstraction the concept of cups ppd files exists for printers that don't use postscript at all but are described by ppd files anyway in the simplest cases the only extra driver you need to print is the ppd file however sometimes ppd files also specify other ppd files or printer-specific binaries in some cases you can pipe the raw job data directly to the printer device and it will work but sometimes you'll need an additional driver to talk in the special messaging protocol that's used by that individual printer the next piece of software to consider is called gtk gdk is a collection of software for creating graphical user interfaces for desktop applications in particular many graphical applications that allow you to print take advantage of gdk libraries for example if i grab the source code for the image editor for gdk print operation run i'll find the following results let's take a look at this file here you can see some of the source code from the image editor this piece of code is calling a gtk library function to print things and here is the implementation of this function inside the gtk source code the gtk source code includes a number of references to different printer back-ends including cups and lpr let's take a look at the gtk back-end for cups as you can see this file is 7100 lines of code something that can be very insightful when trying to debug your printer is to check the log files here's a command that i like to use this command will print out any new statements that are logged to any of these files this log file contains information about crash reports and this log file contains information about things that happen in the kernel this is a general system log there's some overlap between the statements in this file and the statements in this file as we saw before cops is a very important part of printing on linux that's why we should look at any of the cups log files if there's something wrong with printing on your system it's a good idea to check the statements in these log files in the following circumstances immediately after booting your system whenever you plug in or remove your printer whenever you add a new printer through the setup process or whenever you try to print something let's follow these files and see what statements are output when i unplug and replug in my printer here are some statements about my printer being detected the number of statements in these log files can be overwhelming that's why it's useful to use grep to search for specific keywords like cups here we can see a bunch of statements that are related to the cups web server most of these are access denied statements that were issued by app armor in my case these statements aren't causing any problems for me sometimes these access denied statements can be related to the root cause of your problem and the solution would be to give the program the necessary permission or to remove the need for the access entirely here are some other interesting statements this one mentions something about color management and this one mentions something about hp fax failing to create the spool directory this isn't a problem for me but if i was trying to send a fax this statement might be interesting let's grab for the word print and here's a bunch of statements about print jobs that i did recently now let's return to exploring udev rules and kernel events in greater detail on most linux systems this directory contains a number of different udev rules the exact udev rules that are specified here will depend on the distribution of linux that you're using it's also likely to change with every version here's one example of udev rules that are relevant for printers on my system and here's another and another and another in order for a device to be set up properly the correct udev rules need to be run if a device has no matching rule or if it matches the wrong rule you won't get the result that you want you can use the udev adm command to help you debug kernel events and how they interact with udiv for example i can use this command to see what events are triggered when i plug in or remove a usb device now i'll unplug my printer and see what happens now i'll try plugging it back in as you can see there are many events that contain lots of information about the devices i have plugged in here's some information about the printer that i just plugged in you can also use the udev adm command to show information about device nodes here's some information about the device node that corresponds to my printer this shows information not just about the kernel events but also about udev rules that are matched the information shown here is related to the udev rules that we just saw the system udev rules are stored at this location you can override the system udev rules by placing a corresponding rules file at this location for example if i want to override the 55 ipp usb xd rules i can run this command this command will create an empty file at this location the result will be that the system rules at this location will not be run if you're trying to debug any hardware on your system it's useful to poke around at the files at this location the files that are stored here are likely to be different on every linux distribution in fact this is one of the main pieces of work that goes into creating a new distribution in our case for debugging a printer we might want to look at this file or we can even grab the entire directory for the word print here's a bunch of files that contain special cases for certain hp printers okay now let's do a bit of digging to see if we can learn about the printer device files on the system here's the full details on the lp1 device this is what shows up when i plug in my epson printer and take note of these numbers these are called major and minor numbers if we take a look at this location we can see a bunch of sim links to different things on the system so if i look at the full details of those links here you can see a bunch of different references to hardware and if i run this command that uses the same major and minor number that we saw before you can see a bunch of information related to this device here it says the driver is usb lp and as you can see there's lots of different directories and files at this location with information about this device i'm not 100 sure but i believe that this is the source code for that same usb lp driver as you can see this code is only around 1400 lines so this can't possibly have all the information for every printer that's out there i didn't take time to try and understand all this code but it looks like this driver only handles some generic high-level usb communication with the printer rather than trying to understand any low-level printer details here you can see a hard-coded table that appears to list off a few misbehaving printers that suffer from some quirks in this driver some people suggest that you should blacklist the usb lp driver if you want to do that you can do so by adding it to this file the ls mod command will list kernel modules that are currently loaded we can see if usb lp is currently loaded using this command and it is now let's take a look at that other printer device here's the one we want to pay attention to note that it's in group lp here's the major and minor number for this device in my case this is the same device that we just looked at because i only have one printer plugged in right now let's see what files are associated with this device i won't pretend to understand what's in all of these files but you can learn a lot by poking around in here let's take a look at this file yep that's my printer let's take a look at this file here it says that the driver is usb based on what we've seen here it would appear that my printer is accessible through two different drivers in addition there also appears to be two different device nodes associated with this printer okay now let's talk about cups filters so here are the cups filters that are installed on my system the point behind each of these filters is to convert documents from one format to another so some printers except postscript this one looks like it's probably for epson this one's probably for hp now from what i've read in the documentation the cups filters are apparently deprecated but as of 2021 these filters are still used and i have a feeling you'll still be dealing with them many years from now it's useful to understand what these filters are because if the filter's not working correctly then you can bet that you'll have a problem with printing so if you ever have a problem with your printer not working but it only happens for certain file formats it may have something to do with filters so for fun let's try running some of these filters manually from the command line and see if we can print something so here i want to print hello world and this here is the absolute path to the cups filter so this should take text which is what i'm inputting here and convert it to postscript format and i know from experience that i need these environment variables and i also have a bunch of dummy variables here for the filter it stated pretty clearly in the documentation that filters are not meant to be run manually by users and they're not kidding because the api for using these filters is really awful and not fun to work with there's a ton of options and variables that seem to be required in order to run the filter but a lot of the values are actually ignored so let's go ahead and run this filter okay there's our output and this appears to be a postscript file so there's our text hello world now for fun let's take this postscript file and pipe it directly to the printer device and see what happens i'm using sudo and wrapping this in a shell here because i need elevated privileges to pipe to this device i should point out that using sudo and piping random data into files in slash dev can be pretty dangerous so make sure you know what you're doing if you try and emulate this okay let's see what this does okay let's see what this does okay so here's what i got i got the first line of the postscript file and the rest of the pages are all blank and it just keep going until it ran into paper now that result is not completely surprising because apparently that printer does not support being fed postscript files directly it happens to be a brother laser printer so let's look around in our filters for something that goes to br laser so here's one thing so this will go from roster to be our laser but we have text so let's see if there's something that will go to roster so we could do pdf let's see if we can get our text into pdf um okay here's text to pdf so what we can do is go text to pdf pdf to roster and roster to be our laser and then we'll try piping the vr laser output directly to this printer okay so let's run this filter okay there's our pdf and that is a pdf that says hello world so we're on the right track so this will do pdf to raster and this should do roster to vr laser so here's all the stuff at output okay let's try piping this br laser file directly to the printer okay let's try piping this br laser file directly to the printer okay that looks better okay now for fun let's try a more advanced example let's try manually printing an svg file so here is an svg document that is a happy face so if i save that this is the file that i just pasted now the filter for this one is pretty crazy so here's my face.svg and in getting this to work i found that the invocation of this filter needs a whole bunch of environment variables in this case to run the filter i also need to make a reference to the ppd file and to read this ppd file i need elevated privileges so i have to use sudo here i also found that inkscape is a dependency of running this command the first time i ran it it failed so that's an example of a filter specific printing problem so let's run this here's our pdf document of the svg now let's make the raster file and to be our laser file okay let's try to print this okay let's try to print this so and here's what i get now before i move on i want to talk a little bit about how absolutely insane the architecture is of these filters particularly this one so svg to pdf is assembling to vector to pdf and if we open vector to pdf we can see it's a script here you can see it sets an environment variable for the options we specified and here you can see it runs the script cups braille what it does have is a bunch of statements to retrieve printing attributes the get option number function calls get option and get option calls get attribute and git attribute uses grep to search through the ppd file so as we mentioned before the ppd file is a postscript file so we're using grep to extract constants from a piece of source code and that's only if they're not specified in the options variable and best of all the options seem to be mandatory even if they're not used okay now let's try the hello world example with my epson printer so here's our pdf file pdf to roster and roster to epson okay now let's see what happens if i send this to the epson printer okay now let's see what happens if i send this to the epson printer so that didn't do exactly what i wanted and i know from experience that i have to press cancel on this menu otherwise i get stuck in an infinite loop where it constantly asks me to add the paper roll unit so as we saw it is relatively easy to use the cups filters manually and create a file that can be piped directly to my brother laser printer but my epson printer has multiple paper feeds so clearly there's a more complicated protocol needed to instruct it which paper feed to pull from it's possible that there's something else i could specify in the options to the cups filter but i also might need to use one of the cups back ends to send the data in a special way i don't know exactly how to get this to work with the epson printer but hopefully this should be instructive on how to debug this kind of stuff so after all this you're probably wondering how was i able to force my printer to work with linux first i went through the automatic install process without any extra drivers when i did this on a separate computer it auto-detected the printer and i was able to add it but whenever i tried to print i would get the same issue that we previously saw where it would try to print from the wrong tray and endlessly ask me to add a paper roll attachment then i installed the gluten print drivers and re-added the printer with a better driver that was based on the epson p800 although the colors were off a bit and i wasn't able to easily figure out how to print with a custom icc paper profile while i was experimenting with guten print i had a couple instances where it would produce a print that was completely flooded with ink and made a huge mess i didn't do that much test printing with gluten print and i decided to move on and try turbo print instead i installed turboprint and i initially found that it wouldn't detect the printer when attached via usb then i tried adding the printer over ethernet and this worked perfectly the colors looked pretty good right away and i was able to get it to use my custom icc profiles for my paper not being able to print over usb was annoying so i found that if i prevented ipp usb xd from starting up when i plug in a new printer then i could get it to be detected properly i did this by creating a udev override to prevent it from running whenever a new printer was plugged in after that turboprint was able to find this printer over a usb connection i'm new to the world of color accurate printing so i had to do a lot of test prints to figure out what the right settings are but so far turbo print seems to be the best option if color accuracy is very important to you if you know of any better options that are out there i'd be happy to hear about them in the comments interestingly i also found that ipp usb xd crashes on my other computer that has a fairly freshly installed version of the exact same version of ubuntu 2004 so as of august 2021 what does the future of printing on linux look like i think we're probably going to see a continuation of the confusing mess that blends together multiple deprecated ways of printing this includes things like the usblp module cups lib usb and a few new protocols that are supposedly going to replace all of these things from what i can tell it looks like the industry is trying to move towards the ipp protocol this would imply that the future will involve less searching for magic printer device nodes in slash dev and would instead involve submitting print jobs using an http request to a print server that supports the ipp protocol supposedly most new printers already support this protocol the other thing that i find ambiguous is the future of the cups package it seems that there's some complex politics involving this project and apple corporation this seems to leave the future of this project very uncertain when doing research for this video i also found out about the open printing project according to this page they seem to be doing active development related to the cups package i also found this presentation from only a few months ago it seems to include a vision for future development on cups here you can see that the ipp protocol is emphasized so that's probably a lot to take in but hopefully this guide can help you figure out how to force your printer to work with linux
Info
Channel: RobertElderSoftware
Views: 1,137
Rating: undefined out of 5
Keywords:
Id: v-7yWtBRYLM
Channel Id: undefined
Length: 34min 17sec (2057 seconds)
Published: Fri Sep 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.