検索
ホームページシステムチュートリアル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 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
Pygobjectを使用してLinuxでGUIアプリケーションを作成する方法Pygobjectを使用してLinuxでGUIアプリケーションを作成する方法May 13, 2025 am 11:09 AM

グラフィカルユーザーインターフェイス(GUI)アプリケーションの作成は、アイデアを実現し、プログラムをよりユーザーフレンドリーにする素晴らしい方法です。 Pygobjectは、開発者がLinuxデスクトップにGUIアプリケーションを作成できるようにするPythonライブラリです。

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コンソールファイルマネージャーは、ローカルマシンでファイルを管理する場合、またはリモートのファイルに接続する場合、日々のタスクで非常に役立ちます。ディレクトリのビジュアルコンソール表現は、ファイル/フォルダーの操作をすばやく実行して保存するのに役立ちます

QBITTORRENT:強力なオープンソースBitTorrentクライアントQBITTORRENT:強力なオープンソースBitTorrentクライアントMay 13, 2025 am 10:12 AM

Qbittorrentは、ユーザーがインターネット上でファイルをダウンロードして共有できる人気のオープンソースBittorrentクライアントです。最新バージョンのQbittorrent 5.0は最近リリースされ、新機能と改善が詰め込まれています。 この記事はそうします

Arch Linuxでnginx仮想ホスト、phpmyadmin、およびSSLをセットアップArch Linuxでnginx仮想ホスト、phpmyadmin、およびSSLをセットアップMay 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でグラフィカルなダイアログボックスを作成できるツールです。グラフィカルユーザーインターフェイス(GUI)を作成するためのツールキットであるGTKを使用して、スクリプトに視覚要素を簡単に追加できます。 ゼニティは非常にuです

Linuxのトップ22の最高の音楽プレーヤーLinuxのトップ22の最高の音楽プレーヤーMay 13, 2025 am 09:25 AM

それを彼らの情熱として説明する人もいれば、それをストレス緩和者や日常生活の一部と考える人もいるかもしれません。あらゆる形で、音楽を聴くことは私たちの生活の不可分な部分になりました。音楽は私たちの生活の中でさまざまな役割を果たしています。 時々それ

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。