Lost pacman db

I did somehow delete the pacman database, I think I deleted to much in /var

Now the system basically runs, but pacman seems to have lost its database of installed packages.

For example:

[thomas@roamer ~]$ sudo pacman -Ss okular
extra/okular 25.12.3-1 (kde-applications kde-graphics)
    Document Viewer
extra/okularpart5 23.08.5-3
    Qt5 Okular KPart
[thomas@roamer ~]$

But okular is installed for sure. How can I regenerate the data?

sudo pacman -Syyu

Should do it.

No.

sudo pacman -Syyu
:: Paketdatenbanken werden synchronisiert …
 endeavouros                                                   14,1 KiB  77,5 KiB/s 00:00 [----------------------------------------------------] 100%
 core                                                         122,8 KiB   620 KiB/s 00:00 [----------------------------------------------------] 100%
 extra                                                          8,2 MiB  11,2 MiB/s 00:01 [----------------------------------------------------] 100%
 multilib                                                     129,2 KiB   730 KiB/s 00:00 [----------------------------------------------------] 100%
:: Vollständige Systemaktualisierung wird gestartet …
 Es gibt nichts zu tun
[thomas@roamer ~]$ sudo pacman -Ss okular
extra/okular 25.12.3-1 (kde-applications kde-graphics)
    Document Viewer
extra/okularpart5 23.08.5-3
    Qt5 Okular KPart
[thomas@roamer ~]$ 

Have you deleted /etc/pacman.conf?

No, it exists.

Then you need to recreate and reinstall all the packages, does /var/log/pacman.log exist?

It does exist.

So something like:

cat /var/log/pacman.log | grep -iE "installed|upgraded" | tuc -d ' ' -f 4 > list.txt

This will give you a list of installed and upgraded packages, then:

pacman -S - < list.txt

tuc is a package I use, -d = delimiter, -f = field.

tuc is not installed and I can not install it now.

I think I give up and reinstall the OS… :frowning:

So do you have awk?

awk 'BEGIN { IGNORECASE=1 } /installed|upgraded/ { print $4 }' /var/log/pacman.log > list.txt

Yes, but

sudo pacman -S - < list.txt

gives me too much obscure messages:

[thomas@roamer ~]$ LANG=c sudo pacman -S - < list.txt 
error: target not found: heroic-games-launcher-bin
warning: glibc-2.43+r5+g856c426a7534-1 is up to date -- reinstalling
warning: jansson-2.15.0-1 is up to date -- reinstalling
warning: openssl-3.6.1-1 is up to date -- reinstalling
error: target not found: heroic-games-launcher-bin
warning: cryptsetup-2.8.4-1 is up to date -- reinstalling
warning: pam-1.7.2-2 is up to date -- reinstalling
warning: curl-8.19.0-1 is up to date -- reinstalling
error: target not found: http-parser
error: target not found: ausweisapp
warning: libunistring-1.4.1-1 is up to date -- reinstalling
warning: gettext-1.0-2 is up to date -- reinstalling
error: target not found: ausweisapp
warning: systemd-260.1-1 is up to date -- reinstalling
warning: expat-2.7.5-1 is up to date -- reinstalling
warning: libldap-2.6.13-1 is up to date -- reinstalling
warning: coreutils-9.10-1 is up to date -- reinstalling
warning: iana-etc-20260306-1 is up to date -- reinstalling
warning: libgcrypt-1.12.1-1 is up to date -- reinstalling
warning: eos-update-26.3.1-1 is up to date -- reinstalling
warning: zlib-1:1.3.2-3 is up to date -- reinstalling
warning: audit-4.1.3-1 is up to date -- reinstalling
warning: systemd-libs-260.1-1 is up to date -- reinstalling
warning: hwdata-0.405-1 is up to date -- reinstalling
warning: libp11-kit-0.26.2-1 is up to date -- reinstalling
warning: p11-kit-0.26.2-1 is up to date -- reinstalling
warning: libmakepkg-dropins-20-1 is up to date -- reinstalling
warning: linux-api-headers-6.19-1 is up to date -- reinstalling
error: target not found: /etc/locale.gen
warning: '/etc/locale.gen' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: libasan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libatomic-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgfortran-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgcc-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgomp-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: liblsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libobjc-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libquadmath-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libstdc++-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libtsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libubsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: gcc-libs-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: gnutls-3.8.12-2 is up to date -- reinstalling
warning: libelf-0.194-2 is up to date -- reinstalling
warning: binutils-2.46-1 is up to date -- reinstalling
warning: libsysprof-capture-49.0-2 is up to date -- reinstalling
error: target not found: libfprint-tod
warning: ca-certificates-mozilla-3.122-1 is up to date -- reinstalling
error: target not found: /etc/pacman.d/mirrorlist
warning: '/etc/pacman.d/mirrorlist' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: pacman-mirrorlist-20260213-1 is up to date -- reinstalling
error: target not found: /etc/pacman.d/mirrorlist
warning: '/etc/pacman.d/mirrorlist' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/pacman.d/mirrorlist
warning: '/etc/pacman.d/mirrorlist' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: icu-78.3-1 is up to date -- reinstalling
warning: zstd-1.5.7-3 is up to date -- reinstalling
warning: ncurses-6.6-2 is up to date -- reinstalling
warning: dbus-broker-37-3 is up to date -- reinstalling
warning: dbus-broker-units-37-3 is up to date -- reinstalling
warning: dbus-units-37-3 is up to date -- reinstalling
warning: glib2-2.86.4-1 is up to date -- reinstalling
warning: gmp-6.3.0-3 is up to date -- reinstalling
warning: libgpg-error-1.59-1 is up to date -- reinstalling
error: target not found: heroic-games-launcher-bin
error: target not found: heroic-games-launcher-bin
error: target not found: ktailctl
error: target not found: karton
warning: eos-translations-26.3.1-1 is up to date -- reinstalling
error: target not found: ventoy-bin
warning: gawk-5.4.0-1 is up to date -- reinstalling
warning: gpgme-2.0.1-3 is up to date -- reinstalling
warning: libksba-1.6.8-1 is up to date -- reinstalling
warning: libngtcp2-1.21.0-1 is up to date -- reinstalling
error: target not found: heroic-games-launcher-bin
warning: file-5.47-1 is up to date -- reinstalling
warning: lmdb-0.9.35-1 is up to date -- reinstalling
error: target not found: libfprint-tod
warning: tzdata-2026a-1 is up to date -- reinstalling
error: target not found: yubico-authenticator-bin
warning: libxml2-2.15.2-1 is up to date -- reinstalling
warning: libcap-ng-0.9.1-1 is up to date -- reinstalling
warning: sqlite-3.52.0-1 is up to date -- reinstalling
warning: e2fsprogs-1.47.4-1 is up to date -- reinstalling
warning: libarchive-3.8.6-1 is up to date -- reinstalling
error: target not found: /etc/pacman.d/endeavouros-mirrorlist
warning: '/etc/pacman.d/endeavouros-mirrorlist' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: karton
warning: libseccomp-2.6.0-1 is up to date -- reinstalling
warning: device-mapper-2.03.39-1 is up to date -- reinstalling
error: target not found: ausweisapp
warning: libnghttp2-1.68.1-1 is up to date -- reinstalling
warning: leancrypto-1.7.0-1 is up to date -- reinstalling
error: target not found: /etc/crypttab
warning: '/etc/crypttab' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/fstab
warning: '/etc/fstab' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/group
warning: '/etc/group' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/gshadow
warning: '/etc/gshadow' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/hosts
warning: '/etc/hosts' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/nsswitch.conf
warning: '/etc/nsswitch.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/passwd
warning: '/etc/passwd' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/resolv.conf
warning: '/etc/resolv.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/shadow
warning: '/etc/shadow' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/shells
warning: '/etc/shells' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/subgid
warning: '/etc/subgid' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/subuid
warning: '/etc/subuid' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: filesystem-2025.10.12-1 is up to date -- reinstalling
error: target not found: /etc/locale.gen
warning: '/etc/locale.gen' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: readline-8.3.003-1 is up to date -- reinstalling
warning: bash-5.3.9-1 is up to date -- reinstalling
warning: acl-2.3.2-1 is up to date -- reinstalling
warning: attr-2.5.2-1 is up to date -- reinstalling
warning: util-linux-libs-2.41.3-2 is up to date -- reinstalling
warning: keyutils-1.6.3-3 is up to date -- reinstalling
warning: gdbm-1.26-2 is up to date -- reinstalling
warning: libsasl-2.1.28-5 is up to date -- reinstalling
warning: libevent-2.1.12-5 is up to date -- reinstalling
warning: libverto-0.3.2-5 is up to date -- reinstalling
warning: krb5-1.21.3-2 is up to date -- reinstalling
warning: libxcrypt-4.5.2-1 is up to date -- reinstalling
warning: libtirpc-1.3.7-1 is up to date -- reinstalling
warning: libnsl-2.0.1-1 is up to date -- reinstalling
warning: pambase-20250719-1 is up to date -- reinstalling
warning: lz4-1:1.10.0-2 is up to date -- reinstalling
warning: xz-5.8.2-1 is up to date -- reinstalling
error: target not found: /etc/environment
warning: '/etc/environment' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: libcap-2.77-1 is up to date -- reinstalling
warning: findutils-4.10.0-3 is up to date -- reinstalling
warning: libtasn1-4.21.0-1 is up to date -- reinstalling
warning: libffi-3.5.2-1 is up to date -- reinstalling
warning: ca-certificates-utils-20240618-1 is up to date -- reinstalling
warning: ca-certificates-20240618-1 is up to date -- reinstalling
warning: brotli-1.2.0-1 is up to date -- reinstalling
warning: libidn2-2.3.8-1 is up to date -- reinstalling
warning: libnghttp3-1.15.0-1 is up to date -- reinstalling
warning: nettle-3.10.2-1 is up to date -- reinstalling
warning: libpsl-0.21.5-2 is up to date -- reinstalling
warning: libssh2-1.11.1-1 is up to date -- reinstalling
warning: mpfr-4.2.2-1 is up to date -- reinstalling
warning: json-c-0.18-2 is up to date -- reinstalling
warning: gnulib-l10n-20241231-1 is up to date -- reinstalling
warning: libusb-1.0.29-1 is up to date -- reinstalling
warning: libassuan-3.0.0-1 is up to date -- reinstalling
warning: bzip2-1.0.8-6 is up to date -- reinstalling
warning: pcre2-10.47-1 is up to date -- reinstalling
warning: tpm2-tss-4.1.3-1 is up to date -- reinstalling
warning: libsecret-0.21.7-1 is up to date -- reinstalling
warning: pinentry-1.3.2-2 is up to date -- reinstalling
warning: npth-1.8-1 is up to date -- reinstalling
warning: gnupg-2.4.9-1 is up to date -- reinstalling
warning: grep-3.12-2 is up to date -- reinstalling
error: target not found: /etc/pacman.d/mirrorlist
warning: '/etc/pacman.d/mirrorlist' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: popt-1.19-2 is up to date -- reinstalling
warning: dbus-1.16.2-1 is up to date -- reinstalling
warning: sed-4.9-3 is up to date -- reinstalling
warning: gzip-1.14-2 is up to date -- reinstalling
warning: kbd-2.9.0-1 is up to date -- reinstalling
warning: kmod-34.2-1 is up to date -- reinstalling
warning: shadow-4.18.0-1 is up to date -- reinstalling
warning: util-linux-2.41.3-2 is up to date -- reinstalling
error: target not found: /etc/systemd/timesyncd.conf
warning: '/etc/systemd/timesyncd.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/makepkg.conf
warning: '/etc/makepkg.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/makepkg.conf.d/fortran.conf
warning: '/etc/makepkg.conf.d/fortran.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
error: target not found: /etc/pacman.conf
warning: '/etc/pacman.conf' is a file, did you mean -U/--upgrade instead of -S/--sync?
warning: pacman-7.1.0.r9.g54d9411-1 is up to date -- reinstalling
warning: expac-10-12 is up to date -- reinstalling
[thomas@roamer ~]$ 

Needs tightening up;

awk '/\[ALPM\] (installed|upgraded)/ { print $4 }' /var/log/pacman.log | sort -u > list.txt
[thomas@roamer ~]$ LANG=C sudo pacman -S - < list.txt
warning: acl-2.3.2-1 is up to date -- reinstalling
warning: attr-2.5.2-1 is up to date -- reinstalling
warning: audit-4.1.3-1 is up to date -- reinstalling
error: target not found: ausweisapp
warning: bash-5.3.9-1 is up to date -- reinstalling
warning: binutils-2.46-1 is up to date -- reinstalling
warning: brotli-1.2.0-1 is up to date -- reinstalling
warning: bzip2-1.0.8-6 is up to date -- reinstalling
warning: ca-certificates-20240618-1 is up to date -- reinstalling
warning: ca-certificates-mozilla-3.122-1 is up to date -- reinstalling
warning: ca-certificates-utils-20240618-1 is up to date -- reinstalling
warning: coreutils-9.10-1 is up to date -- reinstalling
warning: cryptsetup-2.8.4-1 is up to date -- reinstalling
warning: curl-8.19.0-1 is up to date -- reinstalling
warning: dbus-1.16.2-1 is up to date -- reinstalling
warning: dbus-broker-37-3 is up to date -- reinstalling
warning: dbus-broker-units-37-3 is up to date -- reinstalling
warning: dbus-units-37-3 is up to date -- reinstalling
warning: device-mapper-2.03.39-1 is up to date -- reinstalling
warning: e2fsprogs-1.47.4-1 is up to date -- reinstalling
warning: eos-translations-26.3.1-1 is up to date -- reinstalling
warning: eos-update-26.3.1-1 is up to date -- reinstalling
warning: expac-10-12 is up to date -- reinstalling
warning: expat-2.7.5-1 is up to date -- reinstalling
warning: file-5.47-1 is up to date -- reinstalling
warning: filesystem-2025.10.12-1 is up to date -- reinstalling
warning: findutils-4.10.0-3 is up to date -- reinstalling
warning: gawk-5.4.0-1 is up to date -- reinstalling
warning: gcc-libs-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: gdbm-1.26-2 is up to date -- reinstalling
warning: gettext-1.0-2 is up to date -- reinstalling
warning: glib2-2.86.4-1 is up to date -- reinstalling
warning: glibc-2.43+r5+g856c426a7534-1 is up to date -- reinstalling
warning: gmp-6.3.0-3 is up to date -- reinstalling
warning: gnulib-l10n-20241231-1 is up to date -- reinstalling
warning: gnupg-2.4.9-1 is up to date -- reinstalling
warning: gnutls-3.8.12-2 is up to date -- reinstalling
warning: gpgme-2.0.1-3 is up to date -- reinstalling
warning: grep-3.12-2 is up to date -- reinstalling
warning: gzip-1.14-2 is up to date -- reinstalling
error: target not found: heroic-games-launcher-bin
error: target not found: http-parser
warning: hwdata-0.405-1 is up to date -- reinstalling
warning: iana-etc-20260306-1 is up to date -- reinstalling
warning: icu-78.3-1 is up to date -- reinstalling
warning: jansson-2.15.0-1 is up to date -- reinstalling
warning: json-c-0.18-2 is up to date -- reinstalling
error: target not found: karton
warning: kbd-2.9.0-1 is up to date -- reinstalling
warning: keyutils-1.6.3-3 is up to date -- reinstalling
warning: kmod-34.2-1 is up to date -- reinstalling
warning: krb5-1.21.3-2 is up to date -- reinstalling
warning: leancrypto-1.7.0-1 is up to date -- reinstalling
warning: libarchive-3.8.6-1 is up to date -- reinstalling
warning: libasan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libassuan-3.0.0-1 is up to date -- reinstalling
warning: libatomic-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libcap-2.77-1 is up to date -- reinstalling
warning: libcap-ng-0.9.1-1 is up to date -- reinstalling
warning: libelf-0.194-2 is up to date -- reinstalling
warning: libevent-2.1.12-5 is up to date -- reinstalling
warning: libffi-3.5.2-1 is up to date -- reinstalling
error: target not found: libfprint-tod
warning: libgcc-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgcrypt-1.12.1-1 is up to date -- reinstalling
warning: libgfortran-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgomp-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libgpg-error-1.59-1 is up to date -- reinstalling
warning: libidn2-2.3.8-1 is up to date -- reinstalling
warning: libksba-1.6.8-1 is up to date -- reinstalling
warning: libldap-2.6.13-1 is up to date -- reinstalling
warning: liblsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libmakepkg-dropins-20-1 is up to date -- reinstalling
warning: libnghttp2-1.68.1-1 is up to date -- reinstalling
warning: libnghttp3-1.15.0-1 is up to date -- reinstalling
warning: libngtcp2-1.21.0-1 is up to date -- reinstalling
warning: libnsl-2.0.1-1 is up to date -- reinstalling
warning: libobjc-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libp11-kit-0.26.2-1 is up to date -- reinstalling
warning: libpsl-0.21.5-2 is up to date -- reinstalling
warning: libquadmath-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libsasl-2.1.28-5 is up to date -- reinstalling
warning: libseccomp-2.6.0-1 is up to date -- reinstalling
warning: libsecret-0.21.7-1 is up to date -- reinstalling
warning: libssh2-1.11.1-1 is up to date -- reinstalling
warning: libstdc++-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libsysprof-capture-49.0-2 is up to date -- reinstalling
warning: libtasn1-4.21.0-1 is up to date -- reinstalling
warning: libtirpc-1.3.7-1 is up to date -- reinstalling
warning: libtsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libubsan-15.2.1+r604+g0b99615a8aef-1 is up to date -- reinstalling
warning: libunistring-1.4.1-1 is up to date -- reinstalling
warning: libusb-1.0.29-1 is up to date -- reinstalling
warning: libverto-0.3.2-5 is up to date -- reinstalling
warning: libxcrypt-4.5.2-1 is up to date -- reinstalling
warning: libxml2-2.15.2-1 is up to date -- reinstalling
warning: linux-api-headers-6.19-1 is up to date -- reinstalling
warning: lmdb-0.9.35-1 is up to date -- reinstalling
warning: lz4-1:1.10.0-2 is up to date -- reinstalling
warning: mpfr-4.2.2-1 is up to date -- reinstalling
warning: ncurses-6.6-2 is up to date -- reinstalling
warning: nettle-3.10.2-1 is up to date -- reinstalling
warning: npth-1.8-1 is up to date -- reinstalling
warning: openssl-3.6.1-1 is up to date -- reinstalling
warning: p11-kit-0.26.2-1 is up to date -- reinstalling
warning: pacman-7.1.0.r9.g54d9411-1 is up to date -- reinstalling
warning: pacman-mirrorlist-20260213-1 is up to date -- reinstalling
warning: pam-1.7.2-2 is up to date -- reinstalling
warning: pambase-20250719-1 is up to date -- reinstalling
warning: pcre2-10.47-1 is up to date -- reinstalling
warning: pinentry-1.3.2-2 is up to date -- reinstalling
warning: popt-1.19-2 is up to date -- reinstalling
warning: readline-8.3.003-1 is up to date -- reinstalling
warning: sed-4.9-3 is up to date -- reinstalling
warning: shadow-4.18.0-1 is up to date -- reinstalling
warning: sqlite-3.52.0-1 is up to date -- reinstalling
warning: systemd-260.1-1 is up to date -- reinstalling
warning: systemd-libs-260.1-1 is up to date -- reinstalling
warning: tpm2-tss-4.1.3-1 is up to date -- reinstalling
warning: tzdata-2026a-1 is up to date -- reinstalling
warning: util-linux-2.41.3-2 is up to date -- reinstalling
warning: util-linux-libs-2.41.3-2 is up to date -- reinstalling
error: target not found: ventoy-bin
warning: xz-5.8.2-1 is up to date -- reinstalling
error: target not found: yubico-authenticator-bin
warning: zlib-1:1.3.2-3 is up to date -- reinstalling
warning: zstd-1.5.7-3 is up to date -- reinstalling
[thomas@roamer ~]$ 

But no real action.

So what does:

sudo pacman -S okular

Now show?

sudo pacman -S okular --overwrite "*"

and now okular is being shown as ‘installed’.

But there is a ton of other packages still missing. No worries, I will reinstall the system now.

1 Like