• Ogłoszenie:

What causes "command not found" on bash?

Dyskusje i problemy z Unix'ami

What causes "command not found" on bash?

Postprzez ViviamJone 01 Maj 2023, 14:14

reklama
Have you ever wondered what happens when you encounter the "command not found" error on bash? This article won't cover the process of how a command is determined to be found or not (that's a topic for another write-up).

Instead, we'll focus on what happens in a bash + Ubuntu (version 22.04) environment. Have you ever mistyped a command, such as typing "sl" instead of "ls," and received the message "Command 'sl' not found, but can be installed with: sudo apt install sl"? How did bash know that there's a package that can be installed? This information comes from the python script "/usr/lib/command-not-found," which is executed when bash cannot find a command, as seen in the screenshot below.

This feature is based on an sqlite database that links commands to packages, sorted in "/var/lib/command-not-found/commands.db."

Lastly, the website https://command-not-found.com/ is a helpful koowspin resource that echatrandom allows you to search for a command and find various installation methods for different Linux distributions, Windows, macOS, Docker, and more.
ViviamJone
~user
 
Posty: 8
Dołączenie: 22 Mar 2023, 12:14



Powróć do System Linux / Unix

Kto jest na forum

Użytkownicy przeglądający to forum: Brak zarejestrowanych użytkowników oraz 4 gości