DEV Community

Yaroslav Polyakov
Yaroslav Polyakov

Posted on

apt-file: which deb package to install to get X?

You need to get file X (e.g. hugo), what package to install?

Long time ago, I got used to visit packages.debian.org, scroll down to second search form "Search the contents of packages" and search there.

It's much easier to search with apt-file right from CLI:
Install:

apt install apt-file
apt-file update
Enter fullscreen mode Exit fullscreen mode

Now search:

$ apt-file search hugo
fish-common: /usr/share/fish/completions/hugo.fish
gargoyle-free: /usr/lib/gargoyle/hugo
hugo: /usr/bin/hugo
hugo: /usr/share/bash-completion/completions/hugo
hugo: /usr/share/doc/hugo/changelog.Debian.amd64.gz
...
Enter fullscreen mode Exit fullscreen mode

but if we will search for 'gcc', we will find 170000+ results because apt-find looks for substring match. (and 30k results for 'mc' substring). We should use -x/--regexp search:

$ apt-file -x search bin/gcc$
gcc: /usr/bin/gcc                         
icecc: /usr/lib/icecc/bin/gcc
nvidia-cuda-toolkit: /usr/lib/nvidia-cuda-toolkit/bin/gcc
pentium-builder: /usr/bin/gcc
Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs