ssh command not found in terminal
Solution 1
Your .bash_profile
appears to contain:
export PATH= /usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin}
This has two problems:
- The space after the
=
and before the value causes the value to be a separate argument toexport
, not part of the new value ofPATH
. Thus, whatexport
sees isPATH=
(setting the PATH to an empty string), and/usr/local/sbin:...
(which isn't an assignment at all, and is thus ignored). - The closing
}
is surely not desired.
Thus, you should modify the file to instead contain:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
...or, more simply:
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
...as export is not needed here: Because PATH is already in the environment, updates are always exported automatically.
Solution 2
The default PATH on macOS is
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
If you run that in your terminal, you'll be back to normal.
If you've modified your .bashrc
file, or similar, to add or change a line like that, remove it, or change it to
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH"
Note in particular that there is not a space after PATH=
; it’s all run together, and if you’ve made a change yours should be structured the same way. If you didn't, you can also just reopen your terminal and everything will be fine.
Related videos on Youtube
walkingbytrees
Updated on September 18, 2022Comments
-
walkingbytrees almost 2 years
I appear to have messed up my terminal (on an OSX if that matters) big time. When I try to
SSH
I get-bash: ssh: command not found
After working with the command suggested to me of
declare -p PATH
I getdeclare -x PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:"
Now I'm lost as to what I did and how to fix it. I'm not very knowledgeable in this area and super frustrated that I clearly dabbled in something I should have left alone.
(Edit, forgot to bring over some other content) When I run
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PS4=':${BASH_SOURCE}:$LINENO+' bash -x -l -i
, The resulting output containing~/.bash_profile
is:/Users/Name/.bash_profile:1+export PATH= /usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin} :/Users/Name/.bash_profile:1+PATH= bash: export: ``/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin': not a valid identifier :/Users/Name/.bash_profile:5+PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin: :/Users/Name/.bash_profile:6+export PATH'
-
Charles Duffy over 6 yearsFrom prior discussion with this user on a StackOverflow iteration of this question, I believe they're updating their path in
.bash_profile
. Unfortunately, I wasn't able to get them to edit the relevant content into the question, vs posting it in a comment, so the details are a bit hard to follow; see stackoverflow.com/questions/48103099/… -
walkingbytrees over 6 yearsSorry about that, I have added the output above. Let me know if there was something else I needed to add.
-
Michael Homer over 6 years@walkingbytrees You need to take the space out after
PATH=
. -
walkingbytrees over 6 yearsThanks! That fixed it. Not sure how the space got in there. I tested it out and everything seems in working order!