Basic Terminal Functions do not work

Discussion in 'Mac Basics and Help' started by imanoreotwe, Dec 8, 2013.

  1. imanoreotwe macrumors newbie

    Joined:
    Dec 8, 2013
    #1
    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?
     
  2. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    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.
     
  3. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #3
    That would be really simple for me but terminal will not let me put in the command to show hidden files :mad:
     
  4. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #4
    What do you get from

    Code:
    /bin/echo $PATH
     
  5. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #5
    Hence why I said to use a widget. Either that, or use absolute paths to the required binaries.
     
  6. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #6
    nothing lol. Just an empty space
     
  7. ElectricSheep macrumors 6502

    ElectricSheep

    Joined:
    Feb 18, 2004
    Location:
    Wilmington, DE
    #7
    Well, that there is your problem. You weren't messing around with anything like .profile or .bash_profile were you?
     
  8. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #8
    I might have been messing around with .profile but that was awhile ago. Way before this problem showed up.
     
  9. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #9
    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.
     
  10. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #10
    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.
     
  11. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #11
    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.
     
  12. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #12
    Did that before and everything was fine on the other account
    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
    
    .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.
    
    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
    
     
  13. chown33, Dec 11, 2013
    Last edited: Dec 11, 2013

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #13
    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 
    
     
  14. imanoreotwe thread starter macrumors newbie

    Joined:
    Dec 8, 2013
    #14
    I'm not sure what my intent was but that fixed it and everything works now. Thank you very much!
     

Share This Page