How to Fix “Command Not Found” in command line - shell

Chances are that you might be getting the following error on your Mac, when you have been trying to run commands in the terminal
and you have already installed the commands
zsh: command not found: git
or
zsh: command not found: curl
The fix is in the answer below

Chances are that something might have gone wrong with the users $PATH on your machine or maybe the actual path where the command is has not been set.
You can just run the command below, this should fix you issue:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
and if you feel like checking the path you can just run :
echo $PATH

Related

VScode integrated terminal suddenly throws an error during initialization

I'm using the most recent VScode on Ubuntu 22.10 and experiencing the following issues while opening ZSH and BASH shells in the integrated terminal. The standard Ubuntu terminal works without errors.
After starting a ZSH integrated terminal:
compdump:138: command not found: mv
/home/user/.oh-my-zsh/oh-my-zsh.sh:56: command not found: mkdir
/home/user/.oh-my-zsh/tools/check_for_upgrade.sh:29: command not found: git
/home/user/.oh-my-zsh/oh-my-zsh.sh:115: command not found: rm
getent:6: command not found: grep
_p9k_init_cacheable:59: command not found: uname
_p9k_init_cacheable:61: command not found: uname
BASH
Command 'uname' is available in the following places
* /bin/uname
* /usr/bin/uname
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
uname: command not found
Just several hours before, it worked just fine. Then I tried to set up Remote SSH to another Linux machine (Fedora 36, with the same sort of errors I was also unable to resolve by googling).
Using the #modified keyword in Settings, I ensured that no unexpected changes had been made. The PATH is the same as in the fully operational standard terminal.
Wondering what could be the issue.
UPDATES.
PATH variable:
/usr/local/cuda-11.7/bin:/home/user/.conda/envs/env/bin:$PATH
The problem.
Unlike the complete PATH expansion in the standard terminal, PATH was expanded partially (omitting /usr/bin, etc.) in the integrated terminal.
Based on this error,
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
I suggest you run,
export PATH="/usr/bin:$PATH"
To add /bin:/usr/bin to your PATH
Having :$PATH in your PATH means that the sheell will add the variable $PATH to the end of your PATH
The cause of the issue the following configuration from the User settings:
terminal.integrated.env.linux": {
"PYTHONPATH": "/media/user:/media/user/common:$PYTHONPATH",
"PATH": "/media/user:/media/user/common:$PATH"
}
While the PYTHONPATH variable is expanded properly in the integrated terminal, the PATH is expanded partially to something shown in the UPDATES section of the question. To build on top of the answer by #Orion447, looking for any potential place where PATH could get corrupted is the approach that likely solves the problem.

Command not found when opening terminal, possible conda issue?

for some reason whenever I open my terminal it immediately prints the following (after the "last login" line of course):
(eval):116: command not found: dirname
(eval):116: command not found: dirname
__add_sys_prefix_to_path:6: command not found: dirname
__add_sys_prefix_to_path:7: command not found: dirname
It appears that terminal still works fine, but I can't seem to figure out what the cause of these errors could be. The only thing I've "changed" in my terminal last time I used it was setting up a conda environment and installing some new packages.
Any ideas?
You have tampered with the PATH variable and your current PATH cannot figure out where your common utilities are located.
try:
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH
Fix the last entry you made in your bash_profile or zshrc file before you started encountering the error.

How to fix the terminal "source" command on OSX Catalina

I try executing the below commands in my terminal.
$ source ~/.bash_profile or . ~/.bash_profile
and the system returns:
-bash: [[-s: command not found
I cannot think of anything extra information to provide.
I kept researching my issue and came across this stackoverflow post
I initially misunderstood the error message to mean the source command was not found. After reading the other post I tried running bash .bash_profile and the result was .bash_profile: line 11: [[-s: command not found. I had an error in my .bash_profile file. I commented out the line and tried running source .bash_profile and it worked.
The initial command not found did not relate to the source command, it related to the file I was running with source.
I hope this helps someone else.

OSX/ how to exit bash in terminal

I was trying to setup home-brew and git(installed) via terminal . After i failed to install home-brew i tried to fix the errors that appeared and terminal entered bash and doesn't accept my commands . I tried quitting the terminal app or exit,logout, restart system etc.
Savvass-MacBook-Pro-2:~ Solen$ clear
-bash: clear: command not found
Savvass-MacBook-Pro-2:~ Solen$
SO your path seems to be wrong. You have to fix it :
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
Then export it :
export PATH;
And that should be enough

Command not found ZSH Error after updating zshrc file

I recently updated some applications and now it is giving me error when I open any new tab in teminal.
Error it is giving:
/Users/priti/.oh-my-zsh/lib/completion.zsh:28: command not found:
whoami /Users/priti/.oh-my-zsh/lib/theme-and-appearance.zsh:10:
command not found: uname
/Users/priti/.oh-my-zsh/lib/theme-and-appearance.zsh:14: command not
found: uname getent:4: command not found: grep
I am sure something is wrong with the updated zshrc file, but I am not able to figure out what exactly the problem in that.
Problems I have faced till now are vi and grepcommand not working.For both output is command not found.
Thanks in advance for the same.
Reinstalling zsh solved the problem.
Some steps I followed after brew update might have caused this problem.

Resources