All of a sudden simple things like chmod, ssh even ls wont work in my terminal and I have no idea why. I have tried reinstalling my os and nothing changed. Can someone help please?
The most common cause of this is that your PATH variable got screwed up. If you can find a way to show hidden files in your home folder - I suggest using a Dashboard widget, since Terminal is of little help - look for a .bashrc or .bash_profile file in the root of your home folder. Open it with a text editor. If you find a path changing command in there - something like:All of a sudden simple things like chmod, ssh even ls wont work in my terminal and I have no idea why. I have tried reinstalling my os and nothing changed. Can someone help please?
export PATH=something
That would be really simple for me but terminal will not let me put in the command to show hidden files![]()
/bin/echo $PATH
Hence why I said to use a widget. Either that, or use absolute paths to the required binaries.That would be really simple for me but terminal will not let me put in the command to show hidden files![]()
What do you get from
Code:/bin/echo $PATH
nothing lol. Just an empty space
Well, that there is your problem. You weren't messing around with anything like .profile or .bash_profile were you?
~/.bash_profile, ~/.profile, ~/.bash_login, ~/.bashrc
If you tried re-installing the OS and it didn't help, then it implies there's something messed up in your user environment. To verify, create a new account and log in that account. Try using the Terminal in that account and verify your path is OK.
Assuming the path is OK in the new account, then check your original account. Assuming you are using bash, then there are several initialization files it could read in your account:
Code:~/.bash_profile, ~/.profile, ~/.bash_login, ~/.bashrc
Verify that if those files exist that they are executable. Check all the contents carefully to see what any of them may be doing with your PATH environment variable. Worst case, rename any of those files away in your account and see if things gets better.
~/.bash_login, ~/.bashrc
Well I cannot findWhen I search for them. That maybe the issue. the other two look fine to my untrained eye.Code:~/.bash_login, ~/.bashrc
/bin/ls -l ~/.*{bash,prof}*
/bin/cat /etc/profile
Did that before and everything was fine on the other accountHow did you search for them?
Did you follow this suggestion:
... To verify, create a new account and log in that account. Try using the Terminal in that account and verify your path is OK.
If so, what happened? If not, try that, then post what happens.
It's possible that the master profile file has been damaged. This is the reason for testing under a different account. If things fail there because PATH is empty, then the fault is probably in the master profile, not a per-user profile.
Copy and paste this exact command into a Terminal window:
Then copy and paste the complete output here.Code:/bin/ls -l ~/.*{bash,prof}*
/bin/ls -l ~/.*{bash,prof}*
-rw------- 1 Usern staff 14274 Dec 11 22:49 /Users/Usern/.bash_history
-rw-r--r-- 1 Usern staff 42 Jul 26 17:09 /Users/Usern/.bash_profile
-rw-r--r-- 1 Usern staff 42 Jul 26 17:09 /Users/Usern/.bash_profile
-rw-r--r-- 1 Usern staff 609 Jan 1 2013 /Users/Usern/.profile
-rw-r--r-- 1 Usern staff 241 Jul 6 2012 /Users/Usern/.profile.macports-saved_2013-01-01_at_01:32:57
If you have any bash profile files, please post them. Someone with more experience may see something you missed.
export PATH=${Users/Usern/platform-tools}
# MacPorts Installer addition on 2012-07-06_at_03:01:15: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
##
# Your previous /Users/Usern/.profile file was backed up as /Users/Usern/.profile.macports-saved_2013-01-01_at_01:32:57
##
# MacPorts Installer addition on 2013-01-01_at_01:32:57: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
The master profile file is /etc/profile. You should post that, too:
then copy and paste the complete output.Code:/bin/cat /etc/profile
/bin/cat /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
Did that before and everything was fine on the other account
export PATH=${Users/Usern/platform-tools}
echo $PATH
/bin/mv ~/.bash_profile ~/broken_profile
echo $PATH
ls -lai ~
/bin/cat /Users/Usern/platform-tools
That's consistent with what you show as the contents of /etc/profile.
Your /etc/profile file looks normal.
What's odd is the contents of ".bash_profile":
Please explain exactly what you expect this to do.Code:export PATH=${Users/Usern/platform-tools}
As a shell variable, it's meaningless. Shell variables simply don't work that way (slashes aren't allowed in variable names).
As an expression hoping to be the contents of the file "/Users/Usern/platform-tools", it's wrong in several ways. First, you'd have to use the back-tick or accent-grave, and second you'd have to use the 'cat' command. Third, you'd have to use the absolute path "/Users/Usern/platform-tools", rather than the relative path shown. Those are just guesses at what you're trying to accomplish, because I honestly can't figure out what your intent is with this expression.
The only thing I can say with certainty is that it will evaluate to nothing, i.e. an empty or null string, which is exactly what you posted previously as being the result of:
Code:echo $PATH
So it's clear to me that ".bash_profile" is what's clearing out the PATH variable, but I have no idea what you want it to be until you explain your intent.
The immediate fix for PATH is to rename or delete ".bash_profile". Use this command:
Then quit and relaunch Terminal.Code:/bin/mv ~/.bash_profile ~/broken_profile
After Terminal relaunches, do this:
If it shows anything at all, try this:Code:echo $PATH
and see if it works. If it works, post the complete output. I want to see the inode numbers of the various files.Code:ls -lai ~
In addition to explaining your intent in the assignment to PATH, please post the output of this:
Code:/bin/cat /Users/Usern/platform-tools