Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

imanoreotwe

macrumors newbie
Original poster
Dec 8, 2013
7
0
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?
 
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:
Code:
export PATH=something
... please post it here.
 
That would be really simple for me but terminal will not let me put in the command to show hidden files :mad:
 
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.
 
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.

Well I cannot find
Code:
~/.bash_login, ~/.bashrc
When I search for them. That maybe the issue. the other two look fine to my untrained eye.
 
Well I cannot find
Code:
~/.bash_login, ~/.bashrc
When I search for them. That maybe the issue. the other two look fine to my untrained eye.

How 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:
Code:
/bin/ls -l ~/.*{bash,prof}*
Then copy and paste the complete output here.


If you have any bash profile files, please post them. Someone with more experience may see something you missed.

The master profile file is /etc/profile. You should post that, too:
Code:
/bin/cat /etc/profile
then copy and paste the complete output.
 
How 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.
Did that before and everything was fine on the other account
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:

Code:
/bin/ls -l ~/.*{bash,prof}*
Then copy and paste the complete output here.

here is the output

Code:
 /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.

.bash_profile
Code:
export PATH=${Users/Usern/platform-tools}
.profile
Code:
# 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:
Code:
/bin/cat /etc/profile
then copy and paste the complete output.

here is that
Code:
/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

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":
Code:
export PATH=${Users/Usern/platform-tools}
Please explain exactly what you expect this to do.

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:
Code:
/bin/mv ~/.bash_profile ~/broken_profile
Then quit and relaunch Terminal.

After Terminal relaunches, do this:
Code:
echo $PATH
If it shows anything at all, try this:
Code:
ls -lai ~
and see if it works. If it works, post the complete output. I want to see the inode numbers of the various files.


In addition to explaining your intent in the assignment to PATH, please post the output of this:
Code:
/bin/cat /Users/Usern/platform-tools
 
Last edited:
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":
Code:
export PATH=${Users/Usern/platform-tools}
Please explain exactly what you expect this to do.

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:
Code:
/bin/mv ~/.bash_profile ~/broken_profile
Then quit and relaunch Terminal.

After Terminal relaunches, do this:
Code:
echo $PATH
If it shows anything at all, try this:
Code:
ls -lai ~
and see if it works. If it works, post the complete output. I want to see the inode numbers of the various files.


In addition to explaining your intent in the assignment to PATH, please post the output of this:
Code:
/bin/cat /Users/Usern/platform-tools

I'm not sure what my intent was but that fixed it and everything works now. Thank you very much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.