0

How to search for all packages installing files into a specific directory.

E.g. I want to list all packages which are writing files into the /etc/apparmor.d directory.

abu_bua
  • 10,473
  • 10
  • 45
  • 62

2 Answers2

1

For the listing limited to the set of installed packages only:

dpkg -S /etc/apparmor.d/

This is helpful when tracking down which installed package(s) placed a particular file.

user535733
  • 58,040
  • 10
  • 106
  • 136
0

First install this package

sudo apt install apt-file

and update the database

sudo apt-file update

Next open a terminal and paste/write the following code into it:

mkdir -p ~/.local/bin
cat << EOF > ~/.local/bin/apt-filesearch
#!/usr/bin/env bash
apt-file search \$1 | cut -f 1 -d ":" | sort -u | tr '\n' ' '
EOF
chmod +x ~/.local/bin/apt-filesearch

This will copy the script apt-filesearch into the ~/.local/bin directory.

Now you search for all packages installing stuff into the e.g. /etc/apparmor.d/ directory:

apt-filesearch /etc/apparmor

This script is also nice if you are searching for libs or header files.

abu_bua
  • 10,473
  • 10
  • 45
  • 62