-bash: ls: command not found [duplicate] - bash

This question already has answers here:
Bash script prints "Command Not Found" on empty lines
(17 answers)
Closed 4 years ago.
I have setup react-native in my system.
I have mac OS X El Capitan.
After completing setup of react native, whenever i open my terminal and type command ls then, it shows "command not found".
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
After executing above two lines in my terminal, everything works fine. ls command is working after that. But once i close my terminal and again open it, ls command stops working and it shows "command not found".
I have also tried to add above two lines in .bash_profile file, but didn't get success. I don't know how to get rid of this issue.

Add following line to you .bash_profile
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
Simply you can do it by following command
echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in" >> ~/.bash_profile
After that please restart your terminal

Related

Terminal modified permanently by vscode

I installed vscode today and followed the steps on tutorials on youtube to set up. My terminal started to act weird after I called python through the terminal and tried to use pip install command but failed. I uninstalled the app, deleted all the relevant files, and tried to reopen the terminal. The terminal still has the same warnings.
I have contacted Apple Tech support and they say my terminal got modified by the app. They asked me to contact the app developer.
I don't know what I did to get where I am now. I would appreciate any help that can bring my terminal back to normal.
Below are the warnings even after I uninstalled the app:
Last login: Wed Jun 10 23:02:45 on ttys000
You have mail.
-bash: Saving: command not found
-bash: ...copying: command not found
-bash: ...saving: command not found
-bash: ...completed.: command not found
-bash: Deleting: command not found
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ZhouChristinas-MacBook-Pro:~ zhouchristina$
Check your shell's startup script, it looks like you have text there that aren't shell commands. I don't know whether you have bash or zsh as your shell, but check all of these files just to be sure:
~/.bashrc
~/.bash_aliases
~/.bash_profile
~/.bash_login
~/.zshrc
~/.zshenv
~/.zprofile
~/.zlogin
~/.profile
Also look into any files that are sourced by these files.

vscode integrated terminal throwing bash error - echo: command not found

On my Macbook, the integrated terminal in VSCODE which is using bash shell is throwing the error "bash: :echo: command not found" as soon as I open it and on every command that I execute in it.
But I dont see this error in my iterm or Terminal though. They both work fine. I am getting this error only in VSCode integrated terminal
It was not happening previously. I am not sure what got changed recently.
I checked if the same issue is happening in iterm and Terminal also or not. But it doesn't happen in them.
Checked the .bash_profile and .bashrc files. But they seem to be fine.
Only place I can find echo command in my bash_profile:
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007";':"$PROMPT_COMMAND";
fi
.bashrc doesn't contain any echo commands
Please let me know why this error is coming in vscode integrated terminal only and how to fix it.
Instead of this:
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007";':"$PROMPT_COMMAND";
Try this one:
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"';

trying to install .bash_profile on terminal [duplicate]

This question already has answers here:
How to set .bash_profile, if it does not exist yet. I want to launch sublime from a command line in Mac
(4 answers)
Closed 3 years ago.
I'm having a very hard time installing flutter when I opened my terminal and tried to open the bash profile and I entered open -e .bash_profile on the therminal, I get error stating that my .bash_profile does not exit please see below, can someone help me I been researching and trying to figured what's wrong and no one seems to have an answer.
Last login: Sun Apr 28 00:06:05 on console
Veasnas-MacBook-Pro:~ veasnamam$ open -e .bash_profile
The file /Users/veasnamam/.bash_profile does not exist.
Veasnas-MacBook-Pro:~ veasnamam$
You easily can create a new, empty .bash_profile by doing a touch ~/.bash_profile.
Afterwards run open -e .bash_profile again.
In my case (MacBook Pro too) the file .bash_profile exists, but is empty (I'm using ZSH anyhow) so don't worry if yours does not exist.

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

Bash error after opening Terminal and running shell scripts (CentOS) [duplicate]

This question already has answers here:
Error message on Terminal launch [duplicate]
(2 answers)
Closed 6 years ago.
Every time I open Terminal in CentOS 6.4, I get the error:
bash: usr/local/bin: No such file or directory
I've checked .bashrc and .bash_profile to see if there are any lines that reference usr/local/bin, but haven't found anything. The same error also appears when I switch to root, or run a shell script.
Is it as simple as adding a backslash in front of usr? Like so--
/usr/local/bin
Still don't know where the error is happening though. Any help is much appreciated. Thanks!
This is strange as the normal bash directory on a centos 6.4 system is /bin/bash, however I would advise you to check the following:
echo $SHELL
It should pull your SHELL environment variable to show you where what shell you are using, normally it looks like this:
SHELL=/bin/bash
If it's different say for example:
SHELL=usr/local/bin/bash
then I would check your passwd file to make sure your users default shell is pointing to the right place.
username:x:601:601::/home/username:/bin/bash
Also I would suggest check where you shell actually lives
which bash
/bin/bash
And make sure everything is pointing to the correct location.

Resources