Linux apt package list

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: enter image description here
  • Synaptic running locally on Ubuntu Desktop: enter image description here

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:

Читайте также:  Virtualbox vs kvm linux

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.

Читайте также:  Linux turn monitor off

Источник

How To List All Packages In A Repository On Ubuntu, Debian Or Linux Mint [APT]

This article explains how to list all the packages available in an Ubuntu, Linux Mint or Debian repository (installed and available for install), be it an official repository or a third-party source like a PPA, and so on.

Below you’ll find 2 ways of listing packages from a repository: using a GUI or from the command line.

List all packages in a Debian, Ubuntu or Linux Mint repository using a GUI

If you want to list all the packages in a repository on your desktop, you can use Synaptic Package Manager.

Synaptic is a graphical package management application for APT (APT being the main command line package manager for Debian and its derivatives).

If you don’t have Synaptic installed, you can install it on Debian, Ubuntu, and any Debian or Ubuntu based Linux distribution, including elementary OS, Linux Mint and so on, by using this command:

sudo apt install synaptic

To list all the packages in a particular software repository using Synaptic, launch the application and click on Origin in the bottom left-hand side of its window. Next, select the repository for which you want to list all available packages (both installed and available for installation) from the list that’s displayed in the left-hand side of Synaptic Package Manager.

For example, here’s Synaptic showing all the packages available in the Google repository, listing Google Chrome stable, beta and unstable, as well as Google Earth Pro and EC:

Synaptic list all packages in a repository on Ubuntu or Debian

As you can see, all the software sources are listed here, including the official repositories.

Launchpad PPA repositories are supported as well. Their name begins with LP-PPA, followed by the actual PPA name. Synaptic lists 2 entries for each PPA — make sure you select the PPA entry ending with /ubuntu-codename , for example /bionic , /cosmic , etc. The entry ending in /now doesn’t list all the available packages in the PPA.

This is a screenshot showing all the packages available in the Ubuntu Graphics Drivers PPA (for Ubuntu 18.10 Cosmic Cuttlefish, since that’s what I’m using), including showing which are installed on my system:

Synaptic list all packages in a repository

I’m not sure why, but some packages are listed multiple times for PPA sources (and only for PPA repositories). That only a display thing, and it doesn’t break any functionality.

List all packages in a repository in Ubuntu, Debian or Linux Mint from the command line

Listing all packages in a repository from the command line in Ubuntu, Debian or Linux Mint is a bit tricky, but still quite easy to do.

Читайте также:  HTML E-mail

There are multiple ways of doing this from the command, but I’ll only list one. The command to list all packages available in repository-name is the one that follows:

grep ^Package /var/lib/apt/lists/repository-name*_Packages | awk '' | sort -u

I’ll explain later on how to find out the repository name from /var/list/apt/lists and how to use it. Before that I’ll explain what this command does:

  • grep ^Package . searches for lines beginning with ^Package in the /var/lib/apt/lists/*_Packages file
  • awk » prints the second column for each line (so it filters out everything but the package name)
  • sort -u sorts the lines and outputs only unique lines (removes duplicates)
ls /var/lib/apt/lists/*_Packages

Since the results may be very long, you can run the command output through more for easier reading:

ls /var/lib/apt/lists/*_Packages | more

If you know part of the repository name (I’m using KEYWORD in the command below as the name), you can filter the ls results using grep , like this:

ls /var/lib/apt/lists/*_Packages | grep KEYWORD

For example, let’s say you want to list all the packages in the official Tor repository, and you know the repository name must contain tor . In this case, you’d use this command to find out the _Packages filename from /var/lib/apt/lists/

ls /var/lib/apt/lists/*_Packages | grep tor

For short queries, some unrelated repositories might be displayed, but it’s still easier to see what you’re looking for using grep than listing all the repositories _Packages files.

Now that you know the _Packages filename, you can list all the packages available in that repository by issuing this command:

grep ^Package /var/lib/apt/lists/some-repository-amd64_Packages | awk '' | sort -u

Use the file containing the architecture for which you want to list all available packages in that repository. The example above is for 64bit ( amd64 ), but you could use i386 for 32bit, etc.

You don’t need the complete repository _Packages filename. Back to my Tor repository example, the _Packages filename for Tor is deb.torproject.org_torproject.org_dists_cosmic_main_binary-amd64_Packages . In this case, you could use deb.torproject followed by *_Packages to simplify things, like this:

grep ^Package /var/lib/apt/lists/deb.torproject*_Packages | awk '' | sort -u

Which outputs the following:

deb.torproject.org-keyring tor tor-geoipdb

Another example. Let’s say you want to see all packages available in the Linux Uprising Oracle Java 11 PPA ( ppa:linuxuprising/java ). You can list them by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net_linuxuprising_java*_Packages | awk '' | sort -u
oracle-java11-installer oracle-java11-set-default

To use this with other PPA repositories, replace linuxuprising with the first part of the PPA name, and java with the second part of the PPA name, and the command will list all the packages from that PPA (both installed and not installed).

You can also list all the packages available in all the PPA repositories you have added on your system, by using:

grep ^Package /var/lib/apt/lists/ppa.launchpad.net*_Packages | awk '' | sort -u

For easy access, you could bookmark this command using Marker commands bookmark manager (while used primarily for searching, HSTR can bookmark commands as well).

Источник

Оцените статью
Adblock
detector