5

Is there any command which can return the full name of the .deb package in ubuntu system if I provided only the name of the package. I know there is a command which gives the information about the package such as version, architecture, etc, but I need the full name in single output which I can use for further use in my web application.

For example:

$ some command Lighttpd
lighttpd_1.4.35-4ubuntu2_amd64.deb
  • 2
    What do you mean by "the .deb package"? – fkraiem Mar 23 '18 at 13:54
  • What do you mean by "full name" do you mean the path like /usr/bin/Lighttpd? In that case a .deb package can contain many executables with different names and sometimes multiple directories. – WinEunuuchs2Unix Mar 24 '18 at 0:57
7

Run below command

apt-cache show lighttpd | grep Filename

Output looks like below.

Filename: pool/universe/l/lighttpd/lighttpd_1.4.35-4ubuntu2_amd64.deb

Below command will give u only the deb file name without the path. apt command can be used instead of apt-cache.

apt-cache show lighttpd | grep Filename | rev | cut -d'/' -f 1 | rev

Output:

lighttpd_1.4.35-4ubuntu2_amd64.deb
| improve this answer | |
  • If you think apt-cache is not doing well. Replace the apt-cache with apt. It will still work. – dedunumax Mar 26 '18 at 5:17
  • 1
    It worked like a charm this is what I was looking for. Thank you so much worked for me. Great appreciation – Vidhi Mar 27 '18 at 11:02
3

In short, no, because there is no direct correlation between an installed debian package, and the filename it was installed from.

You can of course construct the filename you've given an example of, by simply combining the various details about the package which are in the installed packages database, but it is not necessarily an accurate description of the file from which the package came. You could create a script to give you this inaccurate file name in several different languages.

| improve this answer | |
  • apt-cache shows it right? – dedunumax Mar 23 '18 at 13:52
  • apt-cache is not so good with installed packaged I guess. And it doesn't give the full .deb package name. – Vidhi Mar 23 '18 at 13:57
  • You can just pipe all of dpkg -l output into an awk script really, to do it for the list of all installed packages. Also, I don't think apt-cache works for things that are not from an apt repository. – dobey Mar 23 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.