Hello, the beautiful people.
Now, probably one of the most confusing things for new users of a GNU Linux operating system is understanding
how to get new software now on other operating systems like Windows or Mac.
Every time that you want to install a piece of software, you're probably just used to downloading an
executable file, opening it, hitting next.
Next, next, next.
Next.
A load of times avoid avoiding reading terms and conditions, but agreeing anyway and celebrating internally
when your new software is installed.
Now in Linux, it works a bit of a different way.
I mean, you still celebrate internally when the software is installed, but you tend to install it
in a way that is much more integrated, standardized, secure and scalable that is possible with the
other operating systems.
But to get those benefits from using a package manager, we first need to let go of our preconceptions
from Windows and Mac and actually get a solid understanding of what is going on in Linux package management
because it's not the same at all, but it is a lot better.
So in this video you're going to learn about how to search for packages using APT by building off our
existing knowledge of the software repositories.
And we're going to show you how you can search those software repositories using the APT package manager.
And you're also going to learn about how the app package manager uses caching to speed up performance
and ensure that you have a fast installation experience.
So by the end of this video, you're going to be able to know how to search the software repositories
for new packages, and that's going to give you the fundamental understanding that you'll need in order
to install them.
So let's go ahead and get right into it.
Okay.
So as of now, we understand that there are a bunch of packages that exist and there will be using a
package manager called APT to download and install them.
So far so good.
So let's start off by getting the APT program to search for packages.
And let's say that we wanted to search for packages that will help us when working with Microsoft Word
files.
Now Microsoft Word files have conventionally had the extension dot, dock x, so let's find all the
packages that are relevant to the text dock x.
So to do that we would type the command apt dash cache OC Search Dock X and when we do that we see that
we get a few results back with one package per line and we see that for each package we get the name
of the package on the left.
So you can see we've got one here called Dock X to two text.
We've got one here called Lib, Apache and so on.
And then on the right we get a short description about that package.
So this will turn Microsoft s XML files to plain text, and this one is a general markup converter and
it's the libraries for that general markup converter.
So you can see at a glance what, what is available.
And for example, if we wanted to search for things to do with text, we could always use grep and search
for the word text and we would get just a few results there.
So you can also narrow this down using grep.
Okay.
So it appears here that we may be interested in this one here called dock x to txt.
Okay.
So how would we get a bit more information about that?
What we could do if we clear the screen is do is use apt cash show dock x to text.
So instead of apt cast search and then a keyword, we're going to use apt cash show and then the package
name.
And when we enter that, you can see that we get a whole bunch of information about that package.
Now this is exactly the kind of information that's good to pipe through the less command to make it
a bit easier to deal with.
There we go so we can see the package name is Dock X to txt.
It's available for all architectures.
It gives you the version number and it also tells you where it's from.
So it's from the universe repository, the text section in there.
It tells you the maintainers with their contact information tells you where to report any bugs and it
tells you loads of other stuff.
But down here there's also a description and it says it converts Microsoft XML files to plain text and
it gives you more information.
Doc Doctor TXT is a tool that attempts to generate equivalent ASCII text files from the Microsoft Doc
X documents.
Okay.
And you can read that if you wish.
Okay.
So you can see by using apt cash show, we can see plenty of information about the doc x to text package.
So that's a really useful ability there.
Now let me show you something.
So we've done all that with access to the Internet, right?
So if I click up here, you can see that I've got a connected Internet connection.
Well, let me try and disconnect my virtual machine from the Internet and try that again.
So I'm going to turn off my connection.
And you can see now I've got no Internet connection whatsoever.
If I open up Firefox and we'll probably see it, tell us that there's no internet connection.
If I go to somewhere like, I don't know, let's say YouTube.com, it'll tell me that the server's not
found, okay?
Because there's no Internet connection.
So with that, let's try and do it again.
Okay.
Let's search for the term web server.
So if I do apt cache search and I want the term web server because there's, because there's two words
in here, I'm going to enclose them in quotes here.
So they go as one search term rather than two separate search terms.
If I didn't have quotes and I did web server, it says If I search for web on its own and then server
on its own, but I want to search for web server together.
Okay, so apt cache search.
And you see we get actually a whole bunch of results.
So let me clear the screen and pipe that through less to make it a bit easier to handle.
But actually.
Wait a second.
Isn't that quite strange?
How was apt able to search for all these packages without having any internet connection?
Hmm.
And there appears to be a package here called Apache two that gives us the very popular Apache Web server.
Okay, so let's try and get more information about that.
So it's called Apache two.
Let's do apt cash show Apache two and pipe that through less just to make it a bit easier to read.
And yeah, we managed to get information about that, how strange it was to even get detailed information
about the package.
So how is that possible if we don't have an Internet connection?
Well, if the information is not stored on the Internet and it's not being downloaded from the Internet,
then it must be stored somewhere on this computer.
And it is.
So this information is stored in something called a cache.
Now, what's a cache?
Well, having come across, you may have come across the word cache when browsing websites and you know
when your browser gets a bit slow.
So you decide to clear out your browser's cache to speed up performance.
But what is a cache?
Exactly what a cache is a kind of storage place for information that's supposed to be efficient and
easy to access.
To explain this, let me tell you a little story.
So let's say that you wanted to keep looking at a certain website and it was called w-w-what awesome
site dot com.
Now without a cache, every time that you wanted to visit awesome site, your computer would send a
request all the way across the Internet to a computer known as a web server that holds all the files
for w-w-what or sitcom.
And this web server could potentially be across the other side of the world.
And sending messages back and forth can take some time.
But let's say that you visit awesome site and your computer sends a message all the way to the web server
that happens to be on the other side of the world.
After its long journey, your request arrives and it waits patiently in line behind all of the other
requests that have arrived there first.
So after dealing with all the other requests and that have come before you in the queue, the web server
will ask, How can I help?
And your request would say, Can you give me a copy of your home page, please?
And the web server would reply.
Sure.
Let me find it for you.
It's such as ran for a little while and then goes, Oh, here you go, and transmits bit by bit a copy
of that file all the way back to your computer, over the internet, across the entire world.
Now, you can imagine the whole process might take a bit of time, wouldn't it?
Now, without a cache, the next time that you want to access WWE or some sitcom, the same thing happens
all over again.
Your request travels to the side of the world, wait in line and the file is sent bit by bit all the
way back across the world.
And this happens again and again and again.
Now, imagine that it's not just you, but thousands or even millions of people all at the same time
requesting awesome sitcom.
I mean, it is awesome, after all.
And if everyone in the world has to do the same process over and over and over again, you can imagine
that the web server might start to become a bit overburdened.
The queues get really long.
There's a backup on the data highway and your web experience just slows way down.
So to fix this problem, that's where a cache comes in.
That's why cache is come in.
Okay.
So instead of being sort of the only being one copy of the file stored on the web server instead the
very first time your request comes back, your it will keep a copy on the local computer in what's called
a cache.
Now the cache is nothing more than a place to store files locally so that you get performance benefits
later.
Now, the second time that you want to visit, visit, awesome site, your computer doesn't need to
shoot messages all over the internet.
It realizes that awesome sitcoms files are already in your cache, and then it just looks in the cache
on your computer locally and loads the page, which is much, much faster.
Now the only issue is that the cache must be kept up to date with what's on the actual web server.
Otherwise you'll keep viewing an outdated copy of the files.
So that's what a cache is.
Now that we understand what a cache is, we now understand the reason why the command is called apt
cache.
And when we run apt cache search, what we're doing is we're telling the app package manager to look
inside the cache for any packages matching the text that you give it.
So if we did apt cache search text, it's looking inside its cache for all packages that match the word
text.
And if we run apt cache show Apache two, it's going to look for the Apache two package in its cache
and bring up all the information that it's got about it.
So where is this cache then?
Well, on ubuntu the cache is located at slash var slash apt slash lists.
So if we seed into there, let's go ahead and take a look.
Okay, slash var slash, apt slash, sorry, slash, var slash lib slash apt slash lists.
Okay, so now we're in there.
If we take a look, we can see there's a whole bunch of different lists in here.
Let me just list them out into the last command and we can see that we've got a whole bunch of files
in here that are actually just lists of packages.
Now, these are the lists of all the packages available from.
The repositories that have enabled on my system and the lists also cover specific type of packages.
Let me let me clear the screen and let me just maximize it as well and list it out again.
But piping it through the last command with the capital end option.
And this allows us to have some line numbering which will make it a bit easier to explain what I'm talking
about.
So here we are.
We've now got each of the lines with some line numbering.
Now you can see that there's so many different lists in this folder, each with a specific, each containing
list of a specific type of package, depending upon where it came from and what type of computer architecture
it's for.
Now, a lot of mine start with the GB dot archive ubuntu dot com.
Now that's because my nearest Ubuntu archive server will be in the UK because I'm based from the UK.
Okay.
In GB is for Great Britain and because I'm in the UK, that's where it sends its requests because it's
a bit more efficient to send your requests to a server that's closer to you.
But yours might be different depending upon where you are in the world.
Okay, so if you're in the US it might say something like US, dot archive, dot com and so on.
So don't worry about not having GB there.
Everything else should be more or less the same though.
Now on line three, there's a list of available artful packages.
So for the artful code name version of Ubuntu, you can see that we've got the binary packages.
So the pre compiled packages that are for the AMD 64 computer architecture from the main repository.
Okay.
And if we take a look online 15, we can see that we've got again for the artful version, we've got
the binary pre compiled packages for the AMD 64 computer architecture, so 64 bit architecture with
from the restricted repository.
And you can see here we've got some from multiverse and so on.
So the lists are broken up very specifically by where they came from and what they're for.
Okay.
Now these are not the packages that are installed on my computer, but they are the packages that are
available in the software repositories that I've chosen to access.
So these I don't like these aren't lists of packages that I have installed, but are lists of packages
that I could install from the software repositories.
Okay.
So let's take a just take a quick look at one of these files that ends at entry.
Okay.
So let's say that we want to edit the entry for the GCC package that we downloaded a couple of videos
ago.
Well, we know that it's going to be in the main repository because it's open source and it's free software,
but it's not maintained by the community.
So we know that GCC should be the main repository.
We also know that it's pre compiled and it's therefore a binary package.
We didn't have to download GTC and then compile it.
We just installed it straight away in the last few videos, which means it's pre compiled.
So if we look for the list that we see, that's for art for main directory, main repository with a
preconfigured preconfigured 64 bit binaries.
Now let's have a look for that.
So we've got artful and we see four main here we are main binary AMD 64.
So it should be in this list.
So if I just copy that and I add this and I open that up with Nano, so I do nano and paste that if
I can.
There we go.
So now if I press enter, you can see that we've opened the list and we've got a whole bunch of different
packages in here.
And you can see that this is starting to look like the results from APT Cash Show and that's exactly
what happens.
That cache show will just search through the files and print out the the information regarding that
package.
So now that we're in this file, why don't we just go ahead and search for the package called DCC?
So the way we can find that a bit easier, instead of just searching for GCC, you can notice that the
actual package bit starts with the word package, then a colon, then a space, then the actual package
name.
So let's try and do that for GCC.
So we're going to do package colon space, GCC.
And if I press enter, we'll see that we've ended up at the GCC package and you can see that we get
all the information about the GCC package that we installed a few minutes ago.
Okay.
In the last video or so and it comes up.
So let's change the priority from saying optional here to saying optional, but awesome.
Okay.
So if I if I save that right, that file opens it same permission denied because this is a special file
we need to open it with sudo.
Okay.
So it's open it with sudo nano where you can do that as just press the up arrow key, then type sudo
at the beginning and enter your password.
Then we're going to search for package package colon DCC.
There we are.
Then instead of having it say optional, we're going to have it say optional, but awesome with an exclamation
mark.
Of course, save the file and exit.
Okay, now, if we just close the terminal and open it up again.
Okay, now if we do apt cash show GCC and maximize the term a little bit and pipe that through less.
We can see here that it's pulled the information for GCSE and now the priority is optional but awesome,
which is fantastic.
Okay, how cool is that?
So you can see here that what's actually happening is you've got a cache, a I guess a place, a folder
on your computer that stores lists that your package manager can search through regardless of whether
you've got Internet connection or not.
And that is located at slash, var, slash, lib, slap, slash, apt slash lists.
So if we go, that's a massive difficulty to say if you're looking there, you've got all these different
lists, each for specific purposes.
And because we wanted to look for the GCC package, we used a little bit of our understanding of repositories
to understand that the GCSE package would be located in the main repository because it's, it's probably
it's maintained by Canonical because it's so old you see, and you've got the, it's pre compiled,
it's ready to go so it's going to be binary and we are on an amd64 computer architecture.
So that's the list that we're looking at.
So we kind of took this, this file here, this file name which is very long, but it's a file name
nonetheless.
And we took a look at it with Nano and we opened it up and we are, oops, I need to enter my password.
So we opened it up and we saw that this is where when you try to show more information about a package,
the package manager gets this information and we looked for the GCC package, okay?
And we found out that this is where it is.
And then we edited some of that information to demonstrate that this is exactly where the information
is coming from.
So if we now look at APT cash show GCSE, we can see that now that information is no longer optional,
but awesome, but it's just optional.
So now you can see a bit behind the scenes how your package manager is working.
So now we understand that for performance benefits, Aptx saves a cache of all available among two packages
on your local system in the slash via slash lib slash apt slash lists directory, and that's called
the apt cash.
That folder is called the APT Cash and by searching the APT cash using APT cash search and that a search
term apt will search all of the lists in those in that cash in that folder for any package names that
have something to do with that search term.
So it'll search the package name and the package description in all of those lists and return to you
the package names with a little snippet, a little description of each package, so that you can look
for more information if you want.
And you would look for more information using APT Cash show and then the package name that APT Cash
search would give you back.
And this will show you detailed information about the package.
Okay.
Things for anything from the size of it to a description to what it does, who the maintainers are,
where to report bugs and everything that you could possibly know about that package.
Now, all of this is done using lists that are installed in the cache.
So lists are downloaded to the slash via slash lib slash apt slash lists folder.
And all of those files in there are just lists of packages and they all have basically the same format,
but that's where everything is saved and it just uses the lists in that folder to produce all this functionality.
But this makes us wonder how did the lists actually get into the cache in the first place?
And just like any cache, it must be kept up to date, otherwise new packages could be released and
you wouldn't know.
So how do we keep the cache up to date?
Well, you're in luck.
These questions and many more will be answered in the next video.