搜尋
首頁系統教程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
如何使用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可能非常

Linux的前22位最佳音樂播放器Linux的前22位最佳音樂播放器May 13, 2025 am 09:25 AM

有些人可能將其描述為他們的激情,而另一些人可能認為這是緩解壓力或日常生活的一部分。在每種形式上,聆聽音樂已成為我們生活中不可分割的部分。音樂在我們的生活中扮演著不同的角色。 有時候

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

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器