How do I search for available packages from the command-line?
To search for a particular package by name or description:
From the command-line, use:
apt-cache search keyword
where the search keyword can be all or part of a package name or any words used in its description.
apt-cache search proxyincludes 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
lessto 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
apt-cache search .
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 synapticif necessary.
Synaptic on ssh'd server via X forwarding:
Synaptic running locally on Ubuntu Desktop:
@MarkThomas Try `apt-cache policy` too, it gives you more information about the sources.
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.
aptall format the output differently. (None of these require the use of
sudowhen searching for a package.) I prefer using
aptfor 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:
apt search package-name
You could narrow your search with something like: `apt search firefox | grep -A 3 firefox`
Another option to narrow the search: `apt search ^firefox` or `apt search ^firefox$`
@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:
aptitude search xxxxxx
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 :-)
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
$ apt-cache search vsftpd
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.
$ apt-cache pkgnames vsftpd
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
sudo apt-get update
then use "search regex" function in
apt-cachewhere "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 regexor in English. A regex variable equal to . will suffice.
apt-cache search .
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 -dand show only a page at a time using
apt-cache search . |sort -d |less