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>
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中文網其他相關文章!

Linux的主要用途包括:1.服務器操作系統,2.嵌入式系統,3.桌面操作系統,4.開發和測試環境。 Linux在這些領域表現出色,提供了穩定性、安全性和高效的開發工具。

互聯網運行不依賴單一操作系統,但Linux在其中扮演重要角色。 Linux廣泛應用於服務器和網絡設備,因其穩定性、安全性和可擴展性受歡迎。

Linux操作系統的核心是其命令行界面,通過命令行可以執行各種操作。 1.文件和目錄操作使用ls、cd、mkdir、rm等命令管理文件和目錄。 2.用戶和權限管理通過useradd、passwd、chmod等命令確保系統安全和資源分配。 3.進程管理使用ps、kill等命令監控和控制系統進程。 4.網絡操作包括ping、ifconfig、ssh等命令配置和管理網絡連接。 5.系統監控和維護通過top、df、du等命令了解系統運行狀態和資源使用情況。

介紹 Linux是一個強大的操作系統,由於其靈活性和效率,開發人員,系統管理員和電源用戶都喜歡。但是,經常使用長而復雜的命令可能是乏味的

Linux適用於服務器、開發環境和嵌入式系統。 1.作為服務器操作系統,Linux穩定高效,常用於部署高並發應用。 2.作為開發環境,Linux提供高效的命令行工具和包管理系統,提升開發效率。 3.在嵌入式系統中,Linux輕量且可定制,適合資源有限的環境。

簡介:通過基於Linux的道德黑客攻擊數字邊界 在我們越來越相互聯繫的世界中,網絡安全至關重要。 道德黑客入侵和滲透測試對於主動識別和減輕脆弱性至關重要

Linux基礎學習從零開始的方法包括:1.了解文件系統和命令行界面,2.掌握基本命令如ls、cd、mkdir,3.學習文件操作,如創建和編輯文件,4.探索高級用法如管道和grep命令,5.掌握調試技巧和性能優化,6.通過實踐和探索不斷提陞技能。

Linux在服務器、嵌入式系統和桌面環境中的應用廣泛。 1)在服務器領域,Linux因其穩定性和安全性成為託管網站、數據庫和應用的理想選擇。 2)在嵌入式系統中,Linux因其高度定制性和高效性而受歡迎。 3)在桌面環境中,Linux提供了多種桌面環境,滿足不同用戶需求。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

Dreamweaver CS6
視覺化網頁開發工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

Dreamweaver Mac版
視覺化網頁開發工具