6

When I have installed a package using apt, is there a way to find out by which command(s) I can run the installed program(s)?

For instance, the package httpcode is not available as httpcode, and the package description (apt show httpcode) does not explain how to run it. How could I have found out that it’s run via hc from the command line?

There are two slightly hacky workarounds I found:

  1. Assuming that programs are by default installed in usr/bin, I ran ls -ltc | head -n 10 to find recenlty touched files there, and indeed I found hc.

  2. Similarly to 1, dpkg -L httpcode returns a list of files created by installing the package, which also lists /usr/bin/hc.

Is there a better solution to this problem that doesn’t hinge upon the intuition of where the program might be stored on disk?

I also found that man httpcode does open the man page of the program, even though I called it with the package name as argument. Does this always work (if the program provides a manpage)?

11

The locations of files (executables, man-pages and other stuff) should conform Filesystem Hierarchy Standard as a rule.

Personally I solve this problem with one of four methods:

  1. It is known that executables are placed in the directories declared in $PATH environment variable:

    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

    So one can list all package files with dpkg --list (see man dpkg for details) and find files in /bin, /sbin, /usr/bin, /usr/sbin, /usr/games directories. So we can use the following command:

    $ dpkg -L httpcode | grep -E "/bin/|/sbin/|/usr/games/"
    /usr/bin/hc
    

    So we can see that /usr/bin/hc belongs to this package.

  2. List all man-pages:

    $ dpkg -L httpcode | grep "/man/"
    /usr/share/man/man1
    /usr/share/man/man1/hc.1.gz
    

    So we can see that we can use man hc.

  3. For applications with GUI I run search for *.desktop files.

    $ dpkg -L httpcode | grep ".desktop"
    $
    

    In this particular case it will not return anything.

    With some complicated proprietary (or bad-packaged) stuff this method transforms to reading Exec variable in the *.desktop file - here Telegram is an example:

     $ dpkg -L telegram | grep ".desktop"
    /usr/share/applications/telegram.desktop
    
    $ grep Exec $(dpkg -L telegram | grep ".desktop")
    Exec=/opt/telegram/Telegram -- %u
    

    About Exec see Desktop Entry Specification.

  4. For not installed package one can visit https://packages.ubuntu.com and use Search package directories here (for all releases or for selected release), then click on list of files link in the right column of the table:

    list of files link

    and one will get the file list:

    list of files for httpcode package

    This list may interpreted manually or by using searchbar in the browser.

4
  • Is your first solution always feasible, i.e. do package executables always go into some bin directory? – bleistift2 Apr 6 '19 at 14:06
  • 1
    Yes, good-packaged application should conform Filesystem Hierarchy Standard, so its executables should be placed in /bin, /sbin, /usr/bin, /usr/sbin. – N0rbert Apr 6 '19 at 14:17
  • 2
    Your executable has to be in one of the directories of the PATH, or it will not be found typing just the name of the executable in the terminal. – vanadium Apr 6 '19 at 15:11
  • @vanadium, you are right about $PATH. Edited answer to include this approach. – N0rbert Apr 6 '19 at 15:22
0

If you can create a shortcut for it to the desktop by right clicking it in the Linux equivalent to the start menu then you can access the properties of said shortcut.

Then just use the end of the command that shortcut uses, for EG I just found Google Chrome's (google-chrome-stable).

BAM there you go. The command to run anything via terminal and/or launcher

1
  • This works for desktop applications, but not every program has a GUI. For those that do, this answer is indeed quicker than N0rbert’s. – bleistift2 Jan 28 at 8: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.