Pacman - how to query (installed or uninstalled) packages?

I am quite new to manajaro/arch side of the linux street and am trying to get around a little better. One thing I haven’t managed yet is to search for packages (installed or not) using pacman completely.

so my questions are:

  1. how can I query all packages available (not only installed ones which should be covered by the -Q flag)
  2. how can I find all packages containing the string (i.e.) cockpit (so I should get cockpit as well as cockpit-dashboard when querying cockpit [the obvious choise of cockpit* does not work with pacman apparently])

I am aware that the pamac gui is able to do so, but I want to get around in the cli as much as I can.

man pacman is your friend
Or
https://wiki.archlinux.org/index.php/pacman

Hi,

Not really sure if it would be practical to print thousands of lines to your terminal.

Sync,search like this:

pacman -Ss STRING

(that should help you get started, but yes please read the docs for operations)

1 Like

with -Q search only installed , for all use -S

for filter, we can add a pipe and use regex

pacman -Ss | grep "/.*linux" -A1
pacman -Ssq | grep "linux"
pacman -Ssq | grep 'cockpit$'
pacman -Ss | grep -E 'cockpit.*228' -A1

or best we can use pacsearch

pacsearch 'linux.*head'
pacsearch '-de$'
pacsearch '^cockpit$'
2 Likes

thx, everybody. That clears things up quite a bit.

I can add a self-dicovered solution which I came up with based on the suggestion here

pacman -Sl | grep [anystring]

There’s pamac cli as well, which is quite good as well, for example:

[tmo@msi ~]$ pamac
Available actions:
  pamac --version     
  pamac --help, -h     [action]
  pamac search         [options] <package(s)>
  pamac list           [options] <package(s)>
  pamac info           [options] <package(s)>
  pamac install        [options] <package(s)>
  pamac reinstall      [options] <package(s)>
  pamac remove         [options] [package(s)]
  pamac checkupdates   [options]
  pamac update,upgrade [options]
  pamac clone          [options] <package(s)>
  pamac build          [options] [package(s)]
  pamac clean          [options]

see for example pamac list --help

yep it’s under

[tmo@msi ~]$ pacman -S --help
usage:  pacman {-S --sync} [options] [package(s)]
options:
  [...]
  -l, --list <repo>    view a list of packages in a repo

which means you can use it for showing (just as pamac) the contents of (a) specific repo(s)
for example pacman -Sl core or pacman -Sl extra community

1 Like

You can also pipe it to dmenu or, better, rofi -dmenu, so you can try out different strings without having to re-run it every time.