 Today, I want to make a quick video showing you guys how you can downgrade packages on Linux should the need arise. It's not something you're going to have to do very often, but sometimes the need does arise and you need to downgrade a package to a previous version because the new version for whatever reason is broken or buggy. So and the reason I want to make this video today is because package management is quite a bit different on Linux than it is on Windows and right now we have a lot of Windows users actually trying out Linux for the first time. And in Windows, do you install something and it's not working right? Well, you just uninstall it and then go find the previous version on the internet, your previous .exe file, you know, the Windows executable and just install that previous version. In Linux, it's a little trickier because we have package managers that manage all of our packages, the versions of those packages, the dependencies needed for those packages. So typically, when you install a package, say you install Firefox, the web browser on version, whatever it is right now. And then next week, Firefox releases a new updated Firefox. Well, when you update your system, you'll upgrade to that new version of Firefox. But say that new version of Firefox is broken or buggy, it's not working for you. And you want to downgrade to the previous version because you know that was working for you. How do you do that? Well, today I'm going to show you how to do this using the apt package manager, which is the package manager for Debian, Ubuntu, Linux Mint, all the various Debian and Ubuntu based distributions, which covers most of desktop Linux. And I'll also show you guys how to do this on Arch Linux based distributions as well. So let me switch over to my desktop here. And this is a virtual machine of Ubuntu 21.10. And to downgrade a package, what you need to do is you're going to need a terminal. So I'm going to hit Ctrl Alt T in Ubuntu to open a terminal. And then let me go ahead and make it full screen. And I'll zoom in the text so you guys can see the commands. But typically, how you downgrade a package is you sudo apt install package name, which is just the standard command line way to install anything. But you want to do package name equals version. So you want to specify a specific version. That way, if it's just sudo apt install package name, that's always going to be the absolute latest version. But you want to specify a previous version, usually if I can spell version correctly. There you go. So how do you know what version of a package you're on right now? How do you know what previous versions are available to you? Well, in Linux, and this is for all distributions, if you're wondering what version of a program you have, typically they'll have a flag called dash dash version. So if I run Firefox space dash dash version, instead of launching Firefox, it'll actually print out what version of Firefox I'm on right now. It's 94.0. You could also with apt get the version of Firefox that is currently installed on your system. You could do apt list dash a and the name of program, in this case Firefox. And it will list all the available versions of Firefox we could install. And you see one of them, this one here 94.0, and then in brackets it has installed. So that's letting us know that is the version currently installed. There is 93.0, the previous version when released back is still available in the repositories if we wanted to install that. So how do we do that? Well, remember it's sudo apt install package equals version. So in this case, Firefox equals. And then what we want is this middle part here, you know, no spaces. So we didn't need impish. We didn't need AMD 64. We just needed this string here. And what I'm going to do is I'm going to do a control shift C to copy control shift V to paste in the terminal here. And if we did this correctly and give our sudo password, it should warn us that this package is now going to be downgraded because this is kind of unusual downgrading a package very rarely are you going to want to ever go to a previous version. This is typically when a program is broken and you absolutely have to have it for whatever it is you do on your computer. That's the only time you really need to downgrade a program. And I'm going to be honest as somebody that's used desktop Linux primarily for the last 13, 14 years, I have downgraded my programs like six times that I probably had six programs that I've ever had to downgrade for whatever reason. And really most of that has happened in the last four years doing this YouTube channel because some of the programs that I rely on to create video content were the packages that were broken. And those, of course, I had to downgrade to the previous versions that I knew worked because again, this is my job. And I needed those programs to do what I needed to do. But if I hit yes to this, I answered yes for this, yes or no question. It will now downgrade Firefox from 94.0 to 93.0. So let me clear the screen there. One neat tool is apt-show-versions. If you want to get a list of all the programs installed in their current versions, you could use this program here. That's typically not installed by default, at least not here in Ubuntu. So I could sudo apt install apt-show-versions. Let me just quickly show you what this little program is. It's kind of neat. Now that that's installed, I'm going to do apt-show-versions. And if I did dash A dash P and then Firefox, we'll get some information about versions of Firefox that are available. And again, it will tell us which one we have installed, the very first one installed, okay, installed. So that's currently what we have installed 93.0. But of course, 94.0 is the latest one and that's available in the repositories. If you run sudo apt-show-version space-i, that will update a cache, the apt cache. Now that you've done that, if you just do apt-show-versions with no other arguments, I believe it will just give you a list. Yeah, it gives you a list of everything that's currently installed, what their version number is, and whether they're up to date or not. Now apt-show-versions, it's not something you're really going to need. It's an interesting program that's available because it gives you a nice clean list of everything that's installed, what their versions are, and whether they're up to date or not up to date. And that makes it very easy to use regex and things like grip, set, and awk, you know, if you needed to find specific packages, maybe that are not currently up to date. Now let me show you how to downgrade packages on Arch Linux and Arch-based distribution. So let me switch to a VM I have here of Manjaro. Manjaro, of course, is an Arch-based Linux distribution. Now with Arch-based systems, there's several ways you could downgrade a package, but there's several ways I could have downgraded a package in that Ubuntu VM, as well. I just showed you one way, the most common way, which is sudo apt install package equals version. In Arch-based distributions, typically people use a program called downgrade. Downgrade is a bash script, and it is available for installation from the AUR, the Arch user repository. I don't think downgrade is actually installed by default in Manjaro. If I did a where is downgrade, nothing is returned. So let's install it. We can use yay or paru, depending on if what AUR helper you happen to have installed on your system. I think Manjaro KDE has paru installed. So I'm going to install downgrade using paru, and it installs very quickly. Again, it's just a bash script that interacts with Pac-Man. And to use the downgrade script, it's very easy. You're going to need sudo privileges anytime you install or uninstall software. So use sudo, downgrade, name of program. I'm going to use vim. I know I've got vim installed. And it looks like Manjaro has a safety in place. It looks like downgrading from ALA is disabled on the stable branch. To override this behavior, set downgrade underscore from underscore ALA to one. So I think what they're wanting here is sudo, and then downgrade from ALA. I'm just going to do a control shift C, control shift V to copy and paste that, equals one. So since it told us to set that to one, and then downgrade vim. And we get a whole bunch of versions of vim available to us. So many more versions available than in Ubuntu or, you know, Debian-based systems in general. Typically, if you're going to downgrade, many times you're only going to get one other option to downgrade to the previous version. But on ArchBase systems, we have a lot of versions available to us. We can go back several versions previous if we want to. So right now, the version of vim that is installed has this plus sign here, 8, 2, dot 3, 4, 4, 1. Actually, let me bring up another terminal, because we should actually take a look at the man page for downgrade. And you guys should take a look at the man page for downgrade. So we've got a nice little example of what the output from downgrade looks like. And this is just an example on a program called Terraform. And you got the pluses and minuses, and the minuses indicates versions that were previously installed. The plus indicates the version that right now is installed. So that is actually very important information, because you always want to go back if you're downgrading probably to a version you had previously installed, because you know that was working, right? You don't want to just guess at some other version, because it may have problems as well. So let's downgrade to 50 in the list, which is version 8.2.2891, because that was the previous version of them we had installed. And let's see if this works correctly. Warning cannot resolve vim runtime. It's a dependency of vim. The following packages cannot be upgraded due to unreasonable dependencies. Do you want to skip the above package for this upgrade? I'm by default it is no. And it's going to complain that, well, we can't resolve this dependency then. So I actually wasn't aware that we wouldn't be able to downgrade vim, but I'm glad we got that on camera, because I did actually want to talk about this at some point, is that downgrading packages is something you don't want to be doing. This is kind of like a last resort, you know, situation where if you really need something to work and the current version is not working, you downgrade to a previous version, because you're going to run into this situation where the dependencies for that previous version of them, they've already moved on to newer versions, right? And then what are you going to do? You're going to have to downgrade those dependencies to previous versions. And you may end up in a situation where you've got to downgrade, you know, 20, 50, 100 different packages just to downgrade that one program that you need, because all the dependencies also have to be downgraded. And that's what's happening here. Now let me try to downgrade something else. So maybe something like htop, for example, because htop I know doesn't have any real dependencies. So that one would probably be an easy one to demonstrate. Right now we have version 3.1.0 and there's no previous version that we've ever had installed, because there's no minus symbols anywhere. So I'm just going to pick one from the list. I'll pick number nine. And let's see if it will downgrade that for us. It looks like it will downgrade htop to the previous version. Just fine for us. The cool thing about this downgrade script is it adds this here, add htop to ignore packages. You want to answer, yes to that. What this does is it adds htop to an ignore package list where in any time you update your system going forward, you won't automatically get upgraded to that new version of htop. Otherwise, anytime you do a sudo pacman syu, you're just going to be bumped up to that new version of htop. So you want to make sure you add it to that ignore package. So that was just a very quick tutorial on how to downgrade packages on Debian-based distributions and arch-based distributions. It's not very hard to downgrade packages, but once again, it's something you don't really want to be doing. This is kind of a last resort kind of thing. And again, you're going to get into these weird situations. For example, what I did trying to downgrade Vim. I didn't actually know that was going to happen, but I'm glad it did. Where I couldn't downgrade Vim without first going and downgrading a dependency. And then that dependency, I bet it has other dependencies to it where it's those dependencies have to get downgraded. And then you go down this weird rabbit hole where you're downgrading a million packages just to get Vim downgraded. It's not worth it at that point. And what I suggest if you run into a situation like that is try to find a snap flat pack or app image of that program. Because people often ask me, what's the advantages of snap flat pack and app image? Why do they exist? Well, one of the reasons they exist is it can be any version of a program, right? If you, for example, Firefox has app images. If, for whatever reason, the current version of Firefox on your distribution is buggy or broken and you can't downgrade, it's just not possible for you, you can go find an app image of a previous version of Firefox very easily. So that is why those package formats are great. And I know some people are just against snaps, flat packs, app images. I don't want that on my system. Well, sometimes you have to use what you have to use. Do you actually want the program or not? Anyway, I hope this quick tutorial video helped you guys out. Before I go, I want to thank a few special people. I want to thank the producers of the show, Devin Gabe James, Matt Mitchell, Paul Scott West, Akami Allen, Chuck, Commander Ingrid Kurt, Diolka, David Dillon, Gregory Heiko, Lee Maxim, Michael Mike, Nitrix, Erion, Alexander P. Sarge, Infador, Polytech, Raver, Red Prophet, Steven and Willie. These guys, they're my highest-eared patrons over on Patreon without these guys. This little tutorial about how to downgrade a package, it wouldn't have been possible. The show is also brought to you by each and every one of these ladies and gentlemen as well. All these names you're seeing on the screen right now, these are all my supporters over on Patreon because I don't have any corporate sponsors. I'm sponsored by you guys, the community. If you like my work and want to support me, please subscribe to DistroTube over on Patreon. Alright guys, peace. And definitely don't downgrade the kernel unless you have a reason.