How to make the system prompt that htop can be install

Hi

I use Fedora 40.
I use dnf search htop to find out if the package is available on my system.
Then I get the following information:

=== Name Exactly Matched: htop ====
htop.x86_64 : Interactive process viewe

But when I type htop directly I get the following result:

bash: htop: command not found…
Similar command is: ‘top’

Is there any way for the system to automatically prompt me that the htop package can provide this command?
like:

bash: htop: command not found…
Install package ‘htop’ to provide command ‘htop’? [N/y]

Thanks

1 Like

You need to have PackageKit-command-not-found installed for that.

Hi

Thank you for your reply.
But the package is already installed on my system.

Package PackageKit-command-not-found-1.2.8-3.fc40.x86_64 is already installed.

Thanks

Try dnf info htop if it’s installed on your system it’s going to show as installed. I think you don’t have it installed and you need to install it with sudo dnf install htop

2 Likes

Hi

Thank for your reply.
I haven’t installed the package yet, but what I expect is to get the system to automatically prompt me that the package is not installed and assist me in installing it.

But it seems that Fedora 40 failed to prompt that the package is missing and assist in installing the package.

For example, I have not installed the gcc-c++ package yet, but when I try to use the g++ command, I can get the following information:

❯ g++ --version
bash: g++: command not found…
Install package ‘gcc-c++’ to provide command ‘g++’? [N/y]

I want to know why the same prompt function does not work correctly on htop package.

Thanks

My guess off the top of my head would be the package itself is not providing the necessary option (for dnf to work with) as opposed to the system is not providing it.
edit: Also, Bash is going to offer what is available on the system if similar is, which top is similar and part of the system by default.

1 Like

Which shell are you using?

Dude… :joy:

So the “packagekit command not found” should autodetect a missing command, and then suggest it? Does it need any initialization? This should be done by default.

No but the shell doesn’t really know what packages are available does it, unless the package manager or monitor reports it. Those would depend on rpm spec file in all cases wouldn’t it? My (assumption) with the statement is actually that the spec file is somehow missing the necessary info for the package manager to report back with useful installation options.

Well, it did have a suggestion

bash: htop: command not found…
Similar command is: ‘top’

though not the one you wanted or expected. The suggestion was that perhaps you meant to run “top”.

2 Likes

You could read the code of command-not-found to see how it works.
Personally I remove command-not-found as I like my, all to frequent, typos reported to me promptly :wink:

1 Like

Hi

I use the bash shell.

Thanks

Hi

Thank you for your reply.
I’ll look into how command-not-found works.

Yeah you could also easily reimplement it.

Either manually: dnf provides COMMAND

or with a bash function to run this when a ran command is not found

This is apparently a feature of PackageKit-command-not-found. It first looks for similar commands (to catch typos) before searching for uninstalled packages.

It’s configurable though. In /etc/PackageKit/CommandNotFound.conf, you can set SimilarNameSearch=false

4 Likes

Hi

Thank you for your reply.