I'm trying out zsh as an alternative to bash, and I seem to have messed up my system path on my MacBook Air. Here's the path I have in my .zshrc:
export PATH=/usr/local/bin:/usr/local/sbin/:usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
Some commands like vim work properly, but standards like ls and sed are returning errors like the following:
zsh: command not found: ls
I'm pretty sure it's not just a zsh problem, as launching a bash terminal produces similar results.
It seems like I'm missing an important directory in there somewhere. Any suggestions?
export PATH=/usr/local/bin:/usr/local/sbin/:usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
there is a / missing in-front of usr/bin
so it should be
export PATH=/usr/local/bin:/usr/local/sbin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
maybe this solves your problem.
Related
I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)
I met some problems when configure zsh with oh-my-zsh on MAC OSX.
When I type 'ls -l' command, some of the output is blue. I don't know where it's from. I didn't set anything like this:
I guess is it from $CLICOLOR, when I 'echo $CLICOLOR' ,it returns 1. While I didn't find where to modify it.
And by the way, how to customize the color of ls output when using zsh? I tried environment variable like $LSCOLORS in ~/.zshrc which does not work.
Playing with zsh is quiet different from bash and I'm new to zsh. Hope somebody can help me with that. Thanks a lot.
Problem is solved, but I still want to tell some difference between CLICOLOR and 'ls -G' after I tried them many times.
The problem I presented could be raised by both 'CLICOLOR' and 'ls -G' on MAC. If
export CLICOLOR = 1
is added to ~/.bashrc or ~/.zshrc, it means you allowed to use
export LSCOLOR = 'blabla'
to define the colors of ls command. This is independent to 'ls -G', which can also highlight 'ls' output but you cannot customize the color of it. (perhaps there is a not known way you can).
So try both when you meet this problem.
I have encountered some strange characters in Terminal's $PATH variable.
$ echo $PATH
/opt/local/bin:...(many similar entries)...:/usr/local/git/bin??n’export
??n’export is what I'm talking about. How do I remove it? I looked in .bacshrc, .bash_profile and similar files, but everything seemed normal there. Problem is that I can't install some new programs with "broken" $PATH.
I'm using bash in Terminal version 2.7.1 and macOS Sierra — Thanks in advance.
The following
perl -e 'printf q{export %s="%s";},$_,join(":",grep{-d $_&&!$seen{$_}++}split/:/,$ENV{$_}), $_ for(qw(PATH))'
will generate for you an new export PATH=..... line, but with cleaned elements. (e.g. no duplicate entries, and removed all nonexiststent directories).
you should copy and paste the result into your $HOME/.profile instead of the existing PATH line.
Problem solved. Strange entries came from /etc/profile file.
A majority of terminal commands don't work, for example .
ls
sudo
vi
with the error -bash: ls: command not found my path is echo $PATH
“/Users/username/usr/local/bin I get the feeling that “ should not be there but not sure how edit it.
What should the path be and how do I get the path to stay the same?
You need to add more paths to your $PATH variable. Try running whereis ls and check where is the binary of the command.
You can add more paths like this: export PATH=$PATH:NEW_PATH
I had a similar experience recently where a lot of my terminal commands were not being found despite being clearly saved in my bash_profile. After lengthy process of elimination I realised that the issue was caused when I tried to export a new path. The error that I had made was putting a space in the command. So I had to change
export SOMETHING = /path/to/something.apk to
export SOMETHING=/path/to/something.apk
So I would recommend you check all your path declarations to ensure you don't have any white spaces. Also don't forget to source your bash_profile or what ever type of command line shell you use.
I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked