- How do I search for available packages from the command-line?
- 9 Answers 9
- To search for a particular package by name or description:
- To get a list of ALL packages
- Use Synaptic if you have X-forwarding enabled or are on a desktop
- Assuming you want to do all of this from the terminal use the following:
- Using ‘apt search’ and ‘apt show’ Commands to Search and Find Details of Packages in Ubuntu
- Why would you want to use apt search or apt show command?
- Search for available packages using apt search command
- Use apt search for package name only
- Get detailed information on a package using apt show command
- Conclusion
How do I search for available packages from the command-line?
I have successfully installed some packages using the command line ‘sudo apt-get install packagename’ when I have known in advance that those packages are available. But how can I search for or get a list of what is available in the repositories?
9 Answers 9
To search for a particular package by name or description:
where the search keyword can be all or part of a package name or any words used in its description.
For example, apt-cache search proxy includes both these packages:
tinyproxy - A lightweight, non-caching, optionally anonymizing HTTP proxy tircd - ircd proxy to the twitter API
Note: the list may be long, so you can pipe the output to less to make it scrollable one line or one screen at a time, i.e. apt-cache search something | less .
To get a list of ALL packages
Use Synaptic if you have X-forwarding enabled or are on a desktop
Synaptic is often a more convenient way to do this, but requires at least an X server on your end (unless you’re running a desktop environment). Install with sudo apt-get install synaptic if necessary.
- Synaptic on ssh’d server via X forwarding:
- Synaptic running locally on Ubuntu Desktop:
like apt-get , you can just run apt-cache without any arguments and get the short help/cheatsheet info. You can always read the manpages on it for longer help. (i.e. man apt-cache )
Supposing that I’m foolish enough to want to live the results into apt install , is there a smart way to do that? The output from this function is messy. One could use the first word from each line, but there should be an easier way.
Using aptitude , apt-cache , and apt all format the output differently. (None of these require the use of sudo when searching for a package.) I prefer using apt for its readability. It highlights the package name and puts a space between the different packages. It also has [installed] listed next to each package that is already installed. Usage:
@jbrock if your output is not a tty but a pipe like in apt search firefox | grep -A 3 firefox then you should use apt-cache search instead. The output of the apt tool is meant for human consumption and can change without notice. The apt-get and apt-cache tools have stable output that can be used in scripts and pipelines like yours.
You can also use aptitude from the command line:
The annoying thing about this one is that Ubuntu doesn’t seem to give it to you by default. Up until I learnt about apt-cache , I was always having do so apt-get install aptitude on each new box I installed. However, since I can’t find a way to get apt-cache to show me whether it’s installed, I guess I’ll have to keep doing that for a bit 🙂
@paxdiablo Just create two line shell script (second line someting like dpkg —list | grep «$1» ) or add shell function to this effect into your .bash_login . 🙂
The apt-cache command line tool is used for searching apt software package cache. In simple words, this tool is used to search software packages, collects information of packages and also used to search for what available packages are ready for installation on Debian or Ubuntu based systems.
To find out the package name and with it description before installing, use the ‘search‘ flag. Using “search” with apt-cache will display a list of matched packages with short description. Let’s say you would like to find out description of package ‘vsftpd‘, then command would be.
apt-cache search SearchTerm
The possible output would be:
vsftpd - lightweight, efficient FTP server written for security ccze - A robust, modular log coloriser ftpd - File Transfer Protocol (FTP) server yasat - simple stupid audit tool
To find and list down all the packages starting with ‘vsftpd‘, you could use the following command.
You may also want to run the results through a more, or even a grep. For instance:
apt-cache search firefox | grep plugin
Assuming you want to do all of this from the terminal use the following:
first I recommend you update the package index files so the list of all files in the repository you are about to create is up to date
then use «search regex» function in apt-cache where «regex» stands for Regular Expression and is the pattern given to search. For more info about search patterns you can look up manual regex(7) by command man 7 regex or in English. A regex variable equal to . will suffice.
The above will give you ALL the results but it is not in any order that is particularly helpful for browsing.
So finally we can sort by dictionary order using sort -d and show only a page at a time using less .
apt-cache search . |sort -d |less
Unfortunately I don’t have enough rep to add this a comment on the main answer.
But I was trying to find g++- — alike packages with apt-cache search . It’s important to know in this case that keyword is a regular expression so apt-cache search g++- will not have helpful results.
apt-cache search «g[+][+][-]» would be the way to go
apt list is how I recommend searching for packages. If you don’t get any matches or if you’re not sure what the package is named, try wrapping the argument in asterisks to get more results. For instance apt list *chrome* will yield the following:
Listing. chrome-gnome-shell/focal,focal,now 10.1-5 all chromium-chromedriver/focal-updates 1:85.0.4183.83-0ubuntu0.20.04.2 amd64 chromium-lwn4chrome/focal,focal 1.0-3 all google-chrome-beta/stable 99.0.4844.17-1 amd64 google-chrome-stable/stable,now 98.0.4758.80-1 amd64 google-chrome-unstable/stable 100.0.4867.0-1 amd64 mkchromecast-alsa/focal,focal 0.3.8.1-1 all mkchromecast-gstreamer/focal,focal 0.3.8.1-1 all mkchromecast-pulseaudio/focal,focal 0.3.8.1-1 all mkchromecast/focal,focal 0.3.8.1-1 all node-chrome-trace-event/focal,focal 1.0.2-1 all openchrome-tool/focal 1:0.6.0-3build1 amd64 python3-pychromecast/focal,focal 4.1.0-1 all ruby-chromedriver-helper/focal,focal 2.1.0-7 all xserver-xorg-video-openchrome-hwe-18.04/focal 3:14.5 amd64 xserver-xorg-video-openchrome/focal 1:0.6.0-3build1 amd64
Alternatively, if you’d like a description of each package, run apt search —names-only . Make sure to include —names-only for more accurate results.
Using ‘apt search’ and ‘apt show’ Commands to Search and Find Details of Packages in Ubuntu
This is a detailed beginners guide to apt search command. Using apt search and apt show commands, you can get details of the available versions, dependencies, repositories and other important information about packages in Ubuntu.
Have you ever wondered if a certain package is available to install via apt package manager?
Have you wondered if the package offered by Ubuntu repositories are the latest one or not?
The apt package manager in Ubuntu and many other distribution provides two handy apt command options for this purpose.
The apt search command looks for the provided string in the name and description of the packages.
The apt show command provides detailed information on a package:
The commands don’t require you to be root in Ubuntu. Here’s an example of these commands:
Why would you want to use apt search or apt show command?
Let’s say you want to install Gambas programming language in Ubuntu. You are happy with your knowledge of the apt command so you decided to use the command line for installing application.
You open a terminal and use the apt command to install gambas but it results in unable to locate package error.
sudo apt install gambas Reading package lists. Done Building dependency tree Reading state information. Done E: Unable to locate package gambas
Why did Ubuntu not find the gambas package? Because there is no such package called gambas. Instead, it is available as gambas3. This is a situation where you could take the advantage of the apt search command.
Let’s move to apt show command. This command provides detailed information about a package, its repository, dependencies and a lot more.
Knowing what version of a package is available from the official repository could help you in deciding whether you should install it from some other sources.
The apt package manager works on a local database/cache of available packages from various repositories. This database contains the information about the available package version, dependencies etc. It doesn’t contain the entire package itself. The packages are downloaded from the remote repositories.
When you run the sudo apt update command, this cache is created/updated in the /var/lib/apt/lists/ directory. The apt search and apt show commands utilize this cache.
The term package is used for an application, program, software.
Search for available packages using apt search command
Let me continue the gambas example. Say, you search for
It will give you a huge list of packages that have “gambas” in its name or description. This output list is in alphabetical order.
Now, you’ll of course have to make some intelligent prediction about the package you want. In this example, the first result says “Complete visual development environment for Gambas”. This gives you a good hint that this is the main package you are looking for.
Why so many packages associated with gambas? Because a number of these gambas packages are probably dependencies that will installed automatically if you install the gambas3 package. If you use the ‘apt show gambas3‘ command, it will show all the dependencies that will be installed with gambas3 package.
Some of these listed packages could be libraries that a developer may need in some special cases while developing her/his software.
Use apt search for package name only
By default, apt search command looks for the searched term in both the name of the package and its description.
You may narrow down the search by instructing the apt command to search for package names only.
apt search --names-only search_term
If you are following this as a tutorial, give it a try. Check the output with search term ‘transitional’ with and without –names-only option and you’ll see how the output changes.
apt search transitional apt search --names-only transitional
Bonus Tip: You can use ‘apt list –installed’ command to look for installed packages in Ubuntu.
Get detailed information on a package using apt show command
The output of the apt search commands a brief introduction of the packages. If you want more details, use the apt show command.
apt show exact_package_name
The apt show command works on the exact package name and it gives you a lot more information on the package. You get:
- Version information
- Repository information
- Origin and maintainer of the package information
- Where to file a bug
- Download and installation size
- Dependencies
- Detailed description of the package
- And a lot more
You need to give the exact package name otherwise the apt show won’t work. The good thing is that tab completion works apt show command.
As you can see in the previous image, you have plenty of information that you may found helpful.
The apt show command also works on installed packages. In that case, you can see which source the package was installed from. Was it a PPA or some third-party repository or universe or the main repository itself?
Personally, I use apt show a lot. This helps me know if the package version provided by Ubuntu is the latest or not. Pretty handy tool!
Conclusion
If you read my detailed guide on the difference between apt and apt-get commands, you would know that this ‘apt search’ command works similar to ‘apt-cache search‘. There is no such command as “apt-get search”.
The purpose of creating apt command is to give you one tool with only enough option to manage the packages in your Debian/Ubuntu system. The apt-get, apt-cache and other apt tools still exist, and they can be used in scripting for more complex scenarios.
I hope you found this introduction to apt search and apt show commands useful. I welcome your questions and suggestions on this topic.
If you liked it, please share it on various Linux forums and communities you frequent. That helps us a lot. Thank you.