Command Not Found
What is the "command not found" error?
The "command not found" error is a message that appears in the terminal when the shell is unable to locate the executable file or command that you have entered. This can happen for a number of reasons, including:
- You have misspelled the command name.
- The command is not installed on your system.
- The command is installed, but it is not in a directory that is listed in your PATH environment variable.
- The command requires superuser or root privileges to run, and you are not currently running the shell as superuser or root.
How to fix the "command not found" error
To fix the "command not found" error, you need to identify the reason why the error is occurring. Once you have identified the reason, you can take the appropriate steps to fix the error.
- If you have misspelled the command name, simply retype the command name carefully.
- If the command is not installed on your system, you can install it using your distribution's package manager. For example, on Ubuntu, you would use the following command to install the "nmap" command:
sudo apt install nmap
If the command is installed, but it is not in a directory that is listed in your PATH environment variable, you can add the directory to your PATH variable. To do this, open your .bashrc file and add the following line to the end of the file:
export PATH=$PATH:/path/to/directory
If the command requires superuser or root privileges to run, you need to run the command with the sudo command. For example, to run the "nmap" command as root, you would use the following command:
sudo nmap
What exact error user can see depends on his terminal, like zsh, bash or any others
The exact error message that you see may vary depending on the terminal emulator that you are using. For example, in zsh, you might see the following error message:
zsh: command not found: nmap
In bash, you might see the following error message:
bash: nmap: command not found
What top most known errors people are usually getting related to this error
The following are some of the top most known errors that people are usually getting related to the "command not found" error:
command not found: [command name]
zsh: command not found: [command name]
bash: [command name]: command not found
[command name]: command not found
-bash: [command name]: command not found
Other helpful information
Here are some other helpful information about the "command not found" error:
- The "command not found" error can also occur if you are trying to run a command that is not available in the current shell environment. For example, if you are logged into a remote server and you try to run a command that is only available on the local machine, you will get the "command not found" error.
- The "command not found" error can also occur if you are trying to run a command that is not supported by your current shell. For example, if you are using the zsh shell and you try to run a command that is only supported by the bash shell, you will get the "command not found" error.