搜索
首页系统教程LINUX命令 - 毫无根据:在Linux中为不可用的命令建议安装程序包

As you may already know, when we run an unavailable or unrecognized command in Linux, we will get an error message - "bash: command not found". The problem is some of us don't know which packages provides that particular command. Not anymore! Today, I've come across an useful utility called "command-not-found" that helps you by suggesting installation of packages when running an unavailable command in Linux.

For instance, let us say you want to run a command named "leafpad", which is not available in your Linux system. You are not sure which packages provides this command. This is where "command-not-found" utility comes in help.

The command-not-found utility will automatically search the official repositories, when entering an unrecognized or unavailable command. It uses a cache of existing programs and their associated packages to help users in their day-to-day command line work.

Install command-not-found Utility in Linux

The 'command-not-found' utility is available in AUR. So, you can install it using AUR helpers such as Paru or Yay.

$ paru -S command-not-found

Or,

$ yay -S command-not-found

Also, pkgfile package provides command-not-found hook. Just install pkgfile to use command-not-found utility.

$ sudo pacman -S pkgfile

Once it is installed, edit your .bashrc file:

$ vi ~/.bashrc

Add the following line at the end to enable it.

source /usr/share/doc/pkgfile/command-not-found.bash

Update the changes made using command:

$ source ~/.bashrc

On Ubuntu and its derivatives, it comes pre-installed.

Just in case if it is not installed already, you can install it as follows.

$ sudo apt update
$ sudo apt install command-not-found

The system-wide cache is empty. You may want to run 'apt-file update' as root to update the cache.

After installing it, you may need to run the following commands as root to update the system-wide cache.

$ sudo update-command-not-found
$ sudo apt-file update

Suggest Package Installation When Command Not Found in Linux

Now, run any unavailable command, for example leafpad:

It will suggest you which package provides this command. Here is the output from my Arch Linux system.

<strong>$ leafpad</strong> 
Command 'leafpad' not found, but can be installed with:
sudo snap install leafpad

As you see in the above output, the "leafpad" command is provided by leafpad-0.8.18.1-5 package.

Let us try another command on Ubuntu:

<strong>$ emacs</strong>
The program 'emacs' can be found in the following packages:
 * emacs24
 * emacs24-nox
 * e3
 * emacs23
 * emacs23-lucid
 * emacs23-nox
 * emacs24-lucid
 * jove
Try: sudo apt-get install <selected package></selected>

命令 - 毫无根据:在Linux中为不可用的命令建议安装程序包

This is just an example. This utility will suggest installation of packages when you run any unavailable command. Once you removed this utility, it won't suggest anything. It will simply display an output something like below.

"bash: emacs: command not found"

Hope this helps.

以上是命令 - 毫无根据:在Linux中为不可用的命令建议安装程序包的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
对于各种任务,Linux和Windows之间的性能有何不同?对于各种任务,Linux和Windows之间的性能有何不同?May 14, 2025 am 12:03 AM

Linux在服务器和开发环境中性能优异,而Windows在桌面和游戏领域表现更好。1)Linux的文件系统在处理大量小文件时表现出色。2)Linux在高并发和高吞吐量网络场景中表现优异。3)Linux的内存管理在服务器环境中更具优势。4)Linux在执行命令行和脚本任务时效率高,而Windows在图形界面和多媒体应用上表现更好。

如何使用Pygobject在Linux中创建GUI应用程序如何使用Pygobject在Linux中创建GUI应用程序May 13, 2025 am 11:09 AM

创建图形用户界面(GUI)应用程序是使您的想法栩栩如生并使您的程序更加用户友好的绝佳方法。 PygoBject是一个Python库,允许开发人员使用Linux桌面上创建GUI应用程序

如何在Arch Linux中使用PhpMyAdmin安装灯泡如何在Arch Linux中使用PhpMyAdmin安装灯泡May 13, 2025 am 11:01 AM

Arch Linux提供了灵活的尖端系统环境,是用于在小型非关键系统上开发Web应用程序的强大解决方案,因为是一个完全开源的,并且在内核上提供了最新的最新版本

如何在Arch Linux上安装LEMP(NGINX,PHP,MARIADB)如何在Arch Linux上安装LEMP(NGINX,PHP,MARIADB)May 13, 2025 am 10:43 AM

由于其滚动释放模型,它包含了尖端软件Arch Linux的设计和开发以作为服务器运行以提供可靠的网络服务,因为它需要额外的时间进行维护,持续的升级和明智的FI

12必备Linux控制台[终端]文件管理器12必备Linux控制台[终端]文件管理器May 13, 2025 am 10:14 AM

Linux控制台文件管理器在日常任务,在本地计算机上管理文件时或连接到远程时,可能非常有帮助。目录的视觉控制台表示可以帮助我们快速执行文件/文件夹操作和SAV

Qbittorrent:强大的开源Bittorrent客户端Qbittorrent:强大的开源Bittorrent客户端May 13, 2025 am 10:12 AM

Qbittorrent是一个受欢迎的开源Bittorrent客户端,允许用户通过Internet下载和共享文件。最新版本Qbittorrent 5.0最近发行了,并带有新功能和改进。 本文将

ARCH Linux上的设置NGINX虚拟主机,PhpMyAdmin和SSLARCH Linux上的设置NGINX虚拟主机,PhpMyAdmin和SSLMay 13, 2025 am 10:03 AM

以前的Arch Linux LEMP文章仅涵盖了基本内容,从安装网络服务(NGINX,PHP,MYSQL和PHPMYADMIN)以及配置MySQL Server和PhpMyAdmin所需的最小安全性。 这个主题与形式严格有关

Zenity:在外壳脚本中构建GTK对话框Zenity:在外壳脚本中构建GTK对话框May 13, 2025 am 09:38 AM

Zenity是一种工具,可让您使用命令行在Linux中创建图形对话框。它使用GTK,这是​​一种用于创建图形用户界面(GUI)的工具包,使您可以轻松地将视觉元素添加到您的脚本中。 Zenity可能非常

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用