How many times have you noticed a file sitting in a directory and wondered… where did this file come from? Or you are trying to tell a friend how to use a utility but he doesn’t have it installed, and you can’t remember what package you installed to get it.
您注意到文件坐在目录中多少次,并且想知道……该文件来自何处? 或者,您正在尝试告诉朋友如何使用实用程序,但他没有安装该实用程序,并且您不记得安装了哪个软件包才能获得该实用程序。
Sure, you can head over to google, but don’t you always wonder how those people know? It’s simple, install the dlocate utility, which is a faster alternative to dpkg for this type of query.
当然,您可以前往Google,但您是否总是想知道这些人怎么知道的? 很简单,安装dlocate实用程序,对于这种类型的查询,它是dpkg的更快替代方案。
sudo apt-get install dlocate
sudo apt-get install dlocate
You can use the command with the syntax ‘dlocate <filename>’, which will give you this output:
您可以将命令与语法“ dlocate <文件名>”一起使用,这将为您提供以下输出:
$ dlocate flac
$ dlocate flac
libxine1: /usr/lib/xine/plugins/1.1.4/xineplug_flac.solibtunepimp5: /usr/lib/tunepimp/plugins/flac.tppgstreamer0.10-plugins-good: /usr/lib/gstreamer-0.10/libgstflac.soflac: /.flac: /usrflac: /usr/binflac: /usr/bin/flac—– trimmed ——
libxine1:/usr/lib/xine/plugins/1.1.4/xineplug_flac.solibtunepimp5:/usr/lib/tunepimp/plugins/flac.tppgstreamer0.10-plugins-good:/usr/lib/gstreamer-0.10/libgstflac.soflac :/.flac:/ usrflac:/ usr / binflac:/ usr / bin / flac—–修剪-
That’s a lot of output! You can see that there are a lot of filenames that partially match. Better to pass the full path to the filename. In this case, you can use ‘which flac’ to determine which flac command you are using, and then pass the full path to dlocate.
大量的输出! 您会看到有很多文件名部分匹配。 最好将完整路径传递给文件名。 在这种情况下,您可以使用“哪个flac”来确定所使用的flac命令,然后将完整路径传递给dlocate。
$ which flac
$哪一个
/usr/bin/flac
/ usr / bin / flac
$ dlocate /usr/bin/flac
$ dlocate / usr / bin / flac
flac: /usr/bin/flac
flac:/ usr / bin / flac
Now we know that the flac command is found in the package called “flac”. (Yes, this example was very simple) You could even get more creative (use the character next to the 1 key, not a single quote)
现在我们知道在名为“ flac”的软件包中找到了flac命令。 (是的,这个例子非常简单),您甚至可以发挥更大的创造力(使用1键旁边的字符,而不是单引号)
$ dlocate `which flac`
$ dlocate`which flac`
flac: /usr/bin/flac
flac:/ usr / bin / flac
If you don’t feel like installing another utility, you can use the ‘dpkg -S <filename>’ command that is built in, but the output isn’t nearly as fast or organized. Just make sure you pass the full path of the file to either utility and you should get good results.
如果您不想安装其他实用程序,则可以使用内置的'dpkg -S <filename>'命令,但是输出的速度或组织度并不高。 只需确保将文件的完整路径传递给任何一个实用程序,您都将获得良好的结果。
翻译自: https://www.howtogeek.com/howto/ubuntu/using-ubuntu-what-package-did-this-file-come-from/