如何让 APT 列出给定路径下的所有包含文件的软件包

如何让 APT 列出给定路径下的所有包含文件的软件包

我无意中/usr/sbin从几台机器上删除了它们。我想找到一种方法来查询 dpkg 或 apt,以告诉我所有在该路径中包含文件的软件包,以便我可以重新安装它们。

输出应该是包名称的列表。

有人有可用的便利apt-***或查询吗?谢谢。dpkg

答案1

做:dpkg -S /usr/sbin

这将生成一个包含给定目录中文件的包列表。

man dpkg-query

   -S, --search filename-search-pattern...
          Search for packages that own files corresponding to the
          given pattern.  Standard shell wildcard characters can be
          used in the pattern, where asterisk (*) and question mark
          (?) will match a slash, and blackslash (\) will be used as
          an escape character.

          If the first character in the filename-search-pattern is
          none of ‘*[?/’ then it will be considered a substring
          match and will be implicitly surrounded by ‘*’ (as in
          *filename-search-pattern*).  If the subsequent string
          contains any of ‘*[?\’, then it will handled like a glob
          pattern, otherwise any trailing ‘/’ or ‘/.’ will be
          removed and a literal path lookup will be performed.

          This command will not list extra files created by
          maintainer scripts, nor will it list alternatives.

相关内容