Bash Command Not Found, Common Reasons and Solutions

Most of the time in Linux OS we run commands and programs by typing the commands in the Terminal program. However, sometimes when we run the command, we receive an error “bash :command not found”. There can be many reasons for receiving this error. Sometimes, with the minimal installation of OS, we do not see most of the commands in our system. As in minimal deployment, only packages are installed which are necessary to run the operating system while the others are skipped. While sometimes maybe the program is already installed but it is corrupted. This error also occurs if you type the command incorrectly. Therefore, we need to identify the reasons that are causing this error and then need to resolve it.

In this article, we will explain the possible reasons for receiving the “bash command not found” error when attempting to run a command in Terminal. Along with this, we will also discuss some feasible solutions that you should try in order to remove the error and successfully run the commands and programs.

Bash command not found: Common Reasons and solutions

Misspell Error

Misspelling a command is a common mistake that users make when running a command in a shell. All commands for Linux and UNIX are case sensitive and we should type the right command spelling.


Check for:

  • Spelling mistake
  • Spaces among command and the various options
  • Incorrect interchange of characters like 1 with I or l
  • Interchanging of uppercase letters with lowercase letters

Package Not Installed

Sometimes, you receive the “command not found error” because the package is not installed on your system or has been corrupted. To verify if the package is installed in your system, run the following command in Terminal:

$ dpkg –s package-name

It will return the output with the results showing whether the package is installed in your system or not. For instance, you want to run apt-fast command and you are receiving the command not found error, then run the following command in order to check if is installed on your system:

$ dpkg –s apt-fast


In case the package is missing from the system, then you will have to install it using the apt-get command as follows:

$ sudo apt-get install package_name

In above case, it would be:

$ sudo apt-get install apt-fast

Once the package is installed, try running the command in order to check if the error is removed.

Path Is Not Correct

Another major reason you get the “bash command not found” error is that the path it is looking for is incorrect. When a user enters a command, the system searches it for in all locations it knows and when it does not find the command in the searched locations, it returns the error.


Step 1: Find the path of command

First, find the path of the command where it is installed by using “which” or “whereis” command. For instance, you are trying to run the apt-fast command and it is giving the “command not found” error. Run the following command in order to find the location of the apt-fast command.

$ whereis apt-fast


$ which apt-fast

Note down the path in the above output and then find if the above path is in your current search path or not.

Step 2: Find the current search path

To view the current search path, run the following command in Terminal:

$ echo $PATH

PATH (Written in upper case letters) guides the shell about locations to search for the executable files. Most of the commands are commonly found in /usr/bin, /bin and /usr/local/bin paths. When we run any command, it is actually running from these directories.

Step 3: Add command’s path to your search path

If the path of the command is not in your shell’s current search path, then try to add this to your search path as follow:

From the “which” search results, we found that apt-fast is installed in /usr/sbin. To add /usr/sbin to the current search path, use the following command:

$ export PATH=$PATH:/usr/sbin

Now confirm the path you have added using the following command:

$ echo $PATH

To save the changes, run the following command in Terminal

$ source ~/.bashrc

Now again try running the command for which you were receiving the error and see if the error has resolved.

Bash command not found error is encountered by almost every system administrators and users. In this article, we have learned a few solutions which you should give a try in order to resolve this error.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Read filename without extension in Bash

Linux users need to work with files regularly for many purposes. Sometimes the users need to read the basename of the file...

Bash escape quotes

Quoting is used to disable the special meaning of the special characters. There are many shell metacharacters which have...

Associative array in Bash

An array variable is used to store multiple data with index and the value of each array element is accessed by the corresponding...
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019

How to Update Ubuntu Linux

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Hướng dẫn cài đặt Apache CloudStack

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader