22

When I run sudo apt install top, I get E: Unable to locate package top

I searched packages.ubuntu.com for top package on 32 bit Ubuntu 16.04 LTS, but there is none.

I wonder if it's correct or I'm missing something.

6
  • 2
    top should already be installed. You just run top from the command line. Is there something else you are looking for like htop or one of the others?
    – Terrance
    Oct 13, 2016 at 2:54
  • 1
    The top command should already be installed by default on 16.04. Did you try run it? top or sudo top
    – GrannySez
    Oct 13, 2016 at 2:55
  • @Terrance @GrannySez top is already installed, I wonder why it is not in repo
    – Megidd
    Oct 13, 2016 at 3:02
  • I am going to change that to an answer.
    – Terrance
    Oct 13, 2016 at 3:10
  • Updated my answer to help show how to determine the package it is installed with.
    – Terrance
    Oct 13, 2016 at 3:17

2 Answers 2

26

It is probably installed with the procps package. It is also common in all *NIX OSes. If you really need to find what it is installed with, install apt-file first:

sudo apt install apt-file
sudo apt-file update

If you run a which command it will return the folder that it is installed into:

$ which top
/usr/bin/top

Then do a search like this:

apt-file search --regexp '/top$'

It will return a list like this:

broctl: /usr/share/broctl/scripts/helpers/top
crossfire-maps: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
crossfire-maps-small: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
liece: /usr/share/emacs/site-lisp/liece/styles/top
lubuntu-extra-sessions: /usr/share/lxpanel/profile/Lubuntu-Nexus7/panels/top
lxpanel: /etc/xdg/lxpanel/two_panels/panels/top
procps: /usr/bin/top
quilt: /usr/share/quilt/top
trn4: /usr/share/doc/trn4/examples/univ/top
trn4: /usr/share/trn4/HelpFiles/top

Then all you have to do is match the folder, and that is the package at the beginning of the line.

Or, you could combine the statement as one and it should return a more exact result:

$ apt-file search --regexp "^$(which top)$"
procps: /usr/bin/top

Hope this helps!

3
  • 4
    You can just use dpkg -S /usr/bin/top to find out in which installed package the top binary lives. No need to install apt-file.
    – marcelm
    Oct 13, 2016 at 13:54
  • 2
    @marcelm You could write an answer for that if you want. Your answer would cover the case of finding an already installed package that provides a particular file. Otherwise, one would need to use apt-file or packages.ubuntu.com.
    – edwinksl
    Oct 13, 2016 at 14:42
  • 5
    apt-get install procps is the not-so-front-and-center solution here I was looking for. Feb 14, 2019 at 20:37
14

If you are using http://packages.ubuntu.com/ to find packages that provide top, you need to search for top in the "Search the contents of packages" section. The results of such a search are:

File                                                            Packages
/etc/xdg/lxpanel/two_panels/panels/top                          lxpanel
/usr/bin/top                                                    procps
/usr/share/broctl/scripts/helpers/top                           broctl
/usr/share/doc/trn4/examples/univ/top                           trn4
/usr/share/emacs/site-lisp/liece/styles/top                     liece
/usr/share/games/crossfire/maps/santo_dominion/magara/well/top  crossfire-maps, crossfire-maps-small
/usr/share/lxpanel/profile/Lubuntu-Nexus7/panels/top            lubuntu-extra-sessions
/usr/share/quilt/top                                            quilt
/usr/share/trn4/HelpFiles/top                                   trn4

In your case, you are most likely looking for the package that provides /usr/bin/top, which is procps.

Unsurprisingly, the search results are identical to the ones found using apt-file as mentioned in @Terrance's answer.

Not the answer you're looking for? Browse other questions tagged .