Useful debian command: apt-file

In later versions of debian-based systems ¬†there’s a command named “apt-file”, it is used to determine which installation package a certain file can be found in.

This can for example be used when something is missing when you compile from source. It may look as follows:

The compilation failed because the file “raster.h” could not be found. The file is probably missing ¬†and something needs to be installed for it to be put in place. The question then is what is to be installed.
An easy way to determine this is to use the command “apt-file“.

Before running the command it is a good idea to update its database.

Then use the command to search for the missing file.

apt-file lists the packages that substantive set the requested file:

Then you only need to install the desired package and try to compile again. In this case, two different packages that contain the requested file was listed, it should be enough to install one of them.

 

Note:

If you get

when running the “apt-file” command, simply install it by entering:

 

Have fun!

1 comment for “Useful debian command: apt-file

  1. March 11, 2013 at 20:58

    Cool. On OpenSUSE we have a similar command called “cnf”.

Leave a Reply

Your email address will not be published. Required fields are marked *