Hello, you beautiful people.
Now, as you know, there are two sides to every coin.
And now that you've learned how to install packages to your system in this video, we're going to be
covering how you can uninstall packages from your system and make sure that your system is squeaky clean.
So let's just go ahead and get right into it.
Okay.
So in the last few videos we've been messing around with the X11 apps package and we're going to continue
using that as kind of our guinea pig for this video.
So to uninstall a package in Ubuntu, the most basic way to do it is to type sudo apt get remove and
then the package name.
Okay.
So because we are talking about the X11 apps package, we just type pseudo app to get remove and then
X11 apps and that would remove it.
But that's not the preferred way to do it.
And the reason is when you install packages, there are sometimes configuration files that come along
with the packages and if you just remove the package using pseudo app to get remove, then the configuration
files are left behind on your system, taking up space and not being helpful.
Now this can be useful if you want to install the package again in the future and want all your settings
to be the same.
But it's still not really the preferred way to do it.
Instead, to remove a package and all of its configuration files.
What we do is instead of typing sudo app get removed we type sudo apt get purge and then the package
name.
So sudo app get purge X11 apps.
Now the purge will remove the package and its configuration files.
So always use Purge whenever you want to uninstall a package.
So if I go ahead and do that, it's going to go and say, hey, I want to remove this.
Is that okay?
I press Yes.
And it will go through and remove X11 apps and any of its configuration file.
So you can see here it says purging configuration files for X11 apps.
So it's gone ahead and done that.
Now that will have the X 11 apps package 100% removed from the system.
But sometimes when you install packages, you need to install like ten of the different packages as
dependencies.
So you need in order to get the package that you want to install to work, you need like ten other packages
or maybe even 100 of the packages in order to get that one package to work.
And we call those extra packages dependencies.
So if those dependencies are no longer required, but you don't know what they're called, how can you
remove them?
Well, you're in luck in order to remove packages that were installed as dependencies but are no longer
required for any other package on the system.
You can just do sudo if i click the screen sudo apt get auto remove and that's it.
So sudo apt get auto remove.
Now auto remove will automatically remove any dangling dependencies that are no longer required, which
helps you save space on your system.
So if I do that, it's going to tell me there's actually not any that need to be removed.
But you can save a lot of space in this.
So bear in mind, this is all happening across hundreds or even thousands of different packages on your
system.
And having the package manager keep everything in order automatically is a really great asset.
I'm sure you'd agree it beats doing it yourself anyway.
Now whenever you download and install the package, a copy of the package is saved locally on your computer.
Now this package is then unpacked and installed on your system, so that's how it works when you install
a package, downloads itself as a compressed archive, then unpacks itself and installs itself on your
system.
Okay, now, because of that two step process, not only is a package installed on your system, but
a compressed version of it is also saved.
Now, these compressed files usually take up space and aren't really necessary if you already have the
package installed because they're just, you know, an archive.
They're like the wrapper that comes with the stuff.
Okay.
So you can actually save yourself massive amounts of space, sometimes even gigabytes of space, just
by deleting these archives.
Now these archives are stored.
If I, if we go there slash, var, slash cache, slash, apt slash archive.
So if we go there and take a look, we can see there's quite a few little DB files here, some compressed
archives saved in there and you can see the 14x 11 APS, even though we've actually removed it from
the system.
And you can see how large these are by doing LS with the L command and you can see that there's a total
of about ten megabytes in there.
Now, that's not much, but you know, this can easily grow to gigabytes after you keep installing packages
on your system.
It can get quite mad because every package you install comes with its own dependencies and even those
dependencies are saved as copy.
So you can really save a lot of space by removing the stuff from here.
Now you don't have to even be in the folder to remove them.
So if I just head back to our home directory, as you can see, we're in our home directory.
If we run sudo apt get clean, that will delete all of the packages from that directory.
So if we head back up into the slash var slash cache, slash apt slash archives and do an LS, we can
see the now that have all been deleted even though we weren't in that folder.
So if you want to get rid of all that stuff, do sudo apt get clean.
But sometimes you don't want to delete all of those for whatever reason and you only want to get rid
of the stuff.
You want to get rid of those packages, those, those, those archives.
But the ones for packages that can no longer be accessed from the from the actual Ubuntu repositories.
Now this is usually for systems that are very old and want to keep their cache going for years and years
and years and every now and then just, you know, trim the leaves and get rid of their dead packages
that can no longer be downloaded for whatever reason.
And to do that, instead of using pseudo apt get clean, you use auto clean now as just to highlight
clean gets rid of everything of of those in the archive cache.
Now that's different from the from the list cache by the way that's just a this is just a storage space
for, for saved archives and packages and stuff.
So this is a completely different cache, but clean will remove everything in there and auto clean will
check what's in there and only delete the ones that you can no longer download from the repositories
to make sure you don't have stuff in there that you'll never use again.
So there you have it.
A no nonsense guide to uninstalling packages.
So let's review.
We discuss it.
The most basic way to review packages is to use sudo apt get remove and then the package name.
But this is not recommended because it leaves behind configuration files instead use sudo apt get purge
and then the package name.
Now when you install the package, it's likely that other dependency packages were also installed in
order to make that package work and in order to get rid of those dependencies and automatically remove
them from the system as long as they're no longer required.
You would use sudo apt get auto remove to remove any unwanted and any unneeded dependencies.
And just because they were used for one package and you remove that package doesn't mean they're no
longer needed for another.
But don't worry about that.
The package manager is going to take care of all that for you.
Okay.
And you also learn that when a software package is installed, it is first downloaded and saved on your
system in a compressed archive.
In this archive is saved on your system even if the package is installed, and that means it's taking
up space.
It's kind of like the wrapper or the packaging behind the actual thing that you want.
Okay, so to clean up all the packaging and clean up all that stuff, what you've got to do is sudo
apt get clean and that's going to delete all the compressed package archives and save you a heck of
a lot of space.
You'd be surprised sometimes even gigabytes at times, but perhaps you don't want to clean up all of
those packages for some reason.
And they said you just want to clean up the ones that can no longer be downloaded from the abundant
repositories.
So for that you'd use pseudo apt to get auto clean.
So there you have it.
You're beautiful people.
You now know everything that you will ever need to know about package management in Ubuntu and you've
done so unbelievably well that in the next video I would like to congratulate you and have a recap of
what we've learned.
So for some well-deserved praises and a recap, I'll see you in the next video.