Help!!! Lost All Terminal Commands!!!

Discussion in 'Mac Programming' started by Oipiah, Jun 6, 2011.

  1. macrumors newbie

    Joined:
    Jun 6, 2011
    #1
    You're all gonna laugh, but I have been modifying the ~/.profile , /etc/paths , and /etc/paths.d files, and now none of the unix commands work in the terminal except for cd (as far as I can tell.) I don't think it was modifying the ~/.profile that did anything because I have been told that that file is initially blank. Could someone please tell me which file I modified that screwed everything up and also how to get that file back to normal?

    Thanks!
    Cody
     
  2. thread starter macrumors newbie

    Joined:
    Jun 6, 2011
    #2
    Also, when I open terminal this is printed
    dirname: illegal option -- b
    usage: dirname path
    basename: illegal option -- b
    usage: basename string [suffix]
    basename [-a] [-s suffix] string [...]
     
  3. macrumors 6502a

    Joined:
    Apr 1, 2007
    #3
    What did you do exactly and what made you want to mess with /etc/paths????
     
  4. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    After you open terminal, try entering this command.

    Code:
    export PATH=/usr/bin:/usr/sbin:/bin:/sbin
    
    This should restore access to the commands temporarily.

    The errors look like issues with the commands in your ~/.profile and/or ~/.bashrc files.

    It's after horse has bolted, but whenever you playing around with kind of stuff, leave a second Terminal window open before you start. Then when you break your bash environment, you can use the second Terminal window to fix it.

    It might also be wise to have a second tab in the second window running sudo -s just in case you need Admin privileges to fix the break.
     
  5. macrumors 6502a

    Joined:
    Apr 1, 2007
    #5
    Dunno if sudo will still work but you can open a text editor with sudo "/Applications/TextEdit.app/Contents/MacOS/TextEdit" and open /etc/paths and set it to the original paths:

    Code:
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
    Export additional via your ~/.profile with EXPORT PATH = $PATH:/path/to/bin
    not by editing the system defaults.

    By default /etc/paths.d/ should only contain X11 with the content:
    Code:
    /usr/X11/bin
     
  6. thread starter macrumors newbie

    Joined:
    Jun 6, 2011
    #6
    Thank You! that worked! I was messing around with /etc/paths b/c I was told that was the way to hard-wire in aliases. However, I have still not been able to get that to work. Any suggestions?
     
  7. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #7
    WTF. That's soooo not the way to do that.

    Aliases should be put into ~/.bashrc. ~/.profile should source ~/.bashrc at the top.

    BTW I've assumed you're talking about Bash aliases, not Finder aliases.
     
  8. macrumors 6502a

    Joined:
    Apr 1, 2007
    #8
    Just for illustration a real example of a additional path being added and an alias being added:

    Code:
    Hansi:~ hansi$ cat .profile
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    alias showListeners="lsof -i -P | grep LISTEN"
     

Share This Page