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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

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

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay