検索
ホームページシステムチュートリアル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 までご連絡ください。
Linuxの主な目的は何ですか?Linuxの主な目的は何ですか?Apr 16, 2025 am 12:19 AM

Linuxの主な用途には、1。Serverオペレーティングシステム、2。EmbeddedSystem、3。Desktopオペレーティングシステム、4。開発およびテスト環境。 Linuxはこれらの分野で優れており、安定性、セキュリティ、効率的な開発ツールを提供します。

インターネットはLinuxで実行されますか?インターネットはLinuxで実行されますか?Apr 14, 2025 am 12:03 AM

インターネットは単一のオペレーティングシステムに依存していませんが、Linuxはその上で重要な役割を果たしています。 Linuxは、サーバーやネットワークデバイスで広く使用されており、安定性、セキュリティ、スケーラビリティに人気があります。

Linux操作とは何ですか?Linux操作とは何ですか?Apr 13, 2025 am 12:20 AM

Linuxオペレーティングシステムのコアは、コマンドラインインターフェイスで、コマンドラインを介してさまざまな操作を実行できます。 1.ファイルおよびディレクトリ操作は、ファイルとディレクトリを管理するために、LS、CD、MKDIR、RM、その他のコマンドを使用します。 2。ユーザーおよび許可管理は、useradd、passwd、chmod、その他のコマンドを介してシステムのセキュリティとリソースの割り当てを保証します。 3。プロセス管理は、PS、Kill、およびその他のコマンドを使用して、システムプロセスを監視および制御します。 4。ネットワーク操作には、Ping、Ifconfig、SSH、およびネットワーク接続を構成および管理するためのその他のコマンドが含まれます。 5.システムの監視とメンテナンスは、TOP、DF、DUなどのコマンドを使用して、システムの動作ステータスとリソースの使用を理解します。

Linuxエイリアスを使用したカスタムコマンドショートカットで生産性を高めますLinuxエイリアスを使用したカスタムコマンドショートカットで生産性を高めますApr 12, 2025 am 11:43 AM

導入 Linuxは、柔軟性と効率性により、開発者、システム管理者、およびパワーユーザーが好む強力なオペレーティングシステムです。しかし、頻繁に長く複雑なコマンドを使用することは退屈でERです

Linuxは実際に何に適していますか?Linuxは実際に何に適していますか?Apr 12, 2025 am 12:20 AM

Linuxは、サーバー、開発環境、埋め込みシステムに適しています。 1.サーバーオペレーティングシステムとして、Linuxは安定して効率的であり、多くの場合、高電流アプリケーションの展開に使用されます。 2。開発環境として、Linuxは効率的なコマンドラインツールとパッケージ管理システムを提供して、開発効率を向上させます。 3.埋め込まれたシステムでは、Linuxは軽量でカスタマイズ可能で、リソースが限られている環境に適しています。

Linuxで倫理的ハッキングを習得するための必須ツールとフレームワークLinuxで倫理的ハッキングを習得するための必須ツールとフレームワークApr 11, 2025 am 09:11 AM

はじめに:Linuxベースの倫理的ハッキングでデジタルフロンティアを保護します ますます相互に接続されている世界では、サイバーセキュリティが最重要です。 倫理的なハッキングと浸透テストは、脆弱性を積極的に特定し、緩和するために不可欠です

Linuxの基本を学ぶ方法は?Linuxの基本を学ぶ方法は?Apr 10, 2025 am 09:32 AM

基本的なLinux学習の方法は次のとおりです。1。ファイルシステムとコマンドラインインターフェイス、2。LS、CD、MKDIR、3。ファイルの作成と編集などのファイル操作を学習するマスター基本コマンド、4。

Linuxの最も使用は何ですか?Linuxの最も使用は何ですか?Apr 09, 2025 am 12:02 AM

Linuxは、サーバー、組み込みシステム、デスクトップ環境で広く使用されています。 1)サーバーフィールドでは、Linuxは、その安定性とセキュリティにより、Webサイト、データベース、アプリケーションをホストするための理想的な選択肢となっています。 2)埋め込みシステムでは、Linuxは高いカスタマイズと効率で人気があります。 3)デスクトップ環境では、Linuxはさまざまなユーザーのニーズを満たすために、さまざまなデスクトップ環境を提供します。

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衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

Dreamweaver Mac版

Dreamweaver Mac版

ビジュアル Web 開発ツール