Need help with fixing my terminal .bash_profile?

Discussion in 'macOS' started by jredecop, Feb 7, 2011.

  1. jredecop macrumors 6502a

    Joined:
    May 20, 2009
    #1
    I had entered a few commands a few months ago trying to root an android phone and now my terminal will not work.
    Here is what i get, and if I type in anything, just get errors..

    [​IMG]

    Now if I type this in, /usr/bin/pico .bash_profile , i can get to this screen

    [​IMG]

    and this is what i need to delete so that i can get terminal working again..can someone please help me with deleting this profile/command? thanks
     
  2. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #2
    I was under the impression this forum offered a way to upload and attach pictures. It would be helpful if we could see what issues you're having.
     
  3. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #3
    I uploaded pics in my post, are you not seeing them?

    I deleted the info on the second screen now get this when typing /usr/bin/pico .bash_profile

    [​IMG]
     
  4. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #4
    Please enter the following in Terminal and post the output. Please, no image files:

    Code:
    /bin/echo $PATH
     
  5. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #5
    opening terminal
    [​IMG]
    entering command
    [​IMG]
     
  6. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #6
    ok, so i deleted this file

    /usr/bin/pico

    and now my terminal is accepting commands and it looks like this when i open it, this good?

    [​IMG]
     
  7. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #7
    Have no idea what you're doing or what the problem is. pico is an editor; you shouldn't delete it. Can you please stop posting images and let us know what you are doing?
     
  8. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #8
    Sorry..what i did is go into the terminal and type in this command, /usr/bin/pico .bash_profile and what i tried is deleting the

    "export PATH=$
    {PATH}:sdkfolder>/tools"

    [​IMG]

    I THEN went and deleted /usr/bin/pico file. At that point I closed terminal and reopened it. The error that I kept getting before I did this

    "-bash: sdkfolder: No such file or directory"

    went away. But I didnt feel right about deleting the pico file, so I put it back.
    My terminal now seems to be functions properly, which probably has to do with deleting the

    "export PATH=$
    {PATH}:sdkfolder>/tools"

    wording and hitting save. Thanks for all your help. I can now go in and enter commands and it will accept them. Thanks for your time and help.
     
  9. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #9
    There is no need to bother with images.

    You can let us know what is going on by simply typing what you type in terminal right here in the forum. You can copy and paste from terminal right in to your browser.

    Anyway. After reading your posts, I decided to take a look at what's in my .bash_profile. Nothing. Nada. The file does not exist. Try renaming .bash_profile to NOT.bash_profile. This should prevent it from being "sourced" when you launch a terminal. You can immediately test it by simply typing bash at the $ prompt. It would go something like this...

    $ mv .bash_profile NOT.bash_profile
    $ bash

    So while I know you managed to get things working, you didn't have to use pico to edit .bash_profile. You could merely rename it so the OS wouldn't find it. I'm glad you "put pico back" though I'm not sure how you did that. You should never go around deleting things in /usr/bin. The terminal is a very dangerous place. You can make your Mac very stupid very quickly by messing things up in terminal. The terminal is a very powerful place. You can customize OS X to your heart's content in terminal, more than the themes, gadgets and various band aids windows users can resort to. So if after hearing how dangerous terminal is you want to use the terminal anyway...

    So how do you protect yourself from yourself? If bash asks for your password, think about it. Better yet, ctrl-c out of it and come back later after making sure you weren't about to \rm -rf * or while (1) fork.

    Take some time and go through a few online Unix tutorials like this one so you know what dot files are and familiarize yourself with the bash shell and basic scripting. A good book to read is Learning the bash Shell By Cameron Newham, Bill Rosenblatt. It's available as an ebook from google for $15, readable in your browser or on any iThing. You can read quite a bit of it by previewing in google books before you decide whether to buy it.
     
  10. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #10
    Ok thanks. Sorry I'm obvisouly new at this, just trying to fix this and thank you for your help. Here what I get when entering what you typed

    Last login: Mon Feb 7 23:39:02 on ttys000
    unknownf81edfe9dc93:~ jredecop$ bash
    bash-3.2$ mv .bash_profile NOT.bash_profile
    mv: rename .bash_profile to NOT.bash_profile: No such file or directory
    bash-3.2$
     
  11. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #11
    Don't delete pico. It's your text editor--not a script.

    Next, <sdkfolder> has no meaning to your shell. This is something that's used by Xcode on a per-target level, and it's not something that's available to a normal Terminal window.

    Lastly, your export command is spread across two lines and wouldn't work anyway. You're borking your PATH variable.


    Only one of your images is visible to me, and that's the last one. As a result, everything else you've said is effectively gibberish. So, let's start over. What are you trying to do?
     
  12. jredecop thread starter macrumors 6502a

    Joined:
    May 20, 2009
    #12
    Anytime I entered a command in terminal I got this message

    -bash: sdkfolder: No such file or directory

    and thats as far as it would go. Trying to get around that. I have it to where terminal is working now but something still looks wrong...whats the unknown here

    Last login: Mon Feb 7 23:46:06 on ttys000
    unknownf81edfe9dc93:~ jredecop$
     
  13. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #13
    Where "unknownf81edfe9dc9" is showing up should be the hostname of your Mac. In my case it looks like this...

    Last login: Tue Feb 8 00:05:58 on ttys000
    r0ksMac:~ r0k$


    If I type cd Documents, it now looks like this:
    r0ksMac: Documents r0k$

    What you see is hostname: folder user $ or # depending whether you are a user or root. I don't recommend enabling your root account as an inexperienced Unix user. That's an express ticket to nowhere!

    The ~ above is a shortcut that means you are sitting in your "home folder". I'm glad to hear you didn't have a .bash_profile. It's something you don't absolutely need. It's a "startup" script that runs whenever you start a new bash shell and I mean every time. Any command you run first tries to run a bash shell and if there is something mixed up in .bash_profile the command never gets to run. It's best not to have that file around at all. One thing that's not clear is what are you trying to accomplish in terminal in the first place? Just tinkering? Learning about Unix? I really like OS X because I can tinker in terminal whenever I like and it's so much like Linux. I also like OS X because I don't have to bother with terminal unless I feel like it. So again I'm curious about why you are using terminal in the first place?
     
  14. buryyourbrideau macrumors 65816

    buryyourbrideau

    Joined:
    Mar 1, 2005
    Location:
    Chicago
    #14
    I too had an issue with this and I need to remove the bash profile sdktools from my terminal.
     
  15. Jagardn macrumors 6502a

    Joined:
    Apr 18, 2011
    #15
    OP, you obviously don't know much about the terminal. The terminal can be a dangerous place if you are just typing random commands from some website and you don't even know what they do. Be careful!!

    What does it say when you type "cat .bash_profile"?
    If it returns nothing then your profile is empty like it should be.
    If it has something, what is in it?

    To get back to square one you can rename your profile like r0k said.
    mv .bash_profile NOT.bash_profile
    touch .bash_profile
    The mv command will take your current .bash_profile and rename it
    The touch command will create a new blank .bash profile (The way it defaults in Mac OSX)
     
  16. parksilk macrumors newbie

    Joined:
    Jun 15, 2012
    #16
    I'm new to using terminal and am having a similar problem while trying to do a Ruby on Rails tutorial. I think something got corrupted in my .bash_profile, but none of the commands—ls, cd, mv, etc.—are working anymore. Here's a look at the last few lines in terminal:

    Does that make sense to anyone? I also tried opening the .bash_profile to edit it, but the terminal commands for that return "command not found" errors also. I was able to open the file in TextEdit, but it was locked so I couldn't change it. Here's what was inside the file:

    Any help?
     
  17. Mac-Michael macrumors regular

    Joined:
    Jan 13, 2010
    #17
    you have to specify the full path to the command (mv, cd, etc) like so:
    Code:
    /bin/mv
    relaunch Terminal

    if you need to recreate it, put this in it
    Code:
    export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH
     
  18. parksilk macrumors newbie

    Joined:
    Jun 15, 2012
    #18
    Thanks, but my .bash_profile file is not inside /bin, it's just inside my home directory. So is that still what I need to do?

    [​IMG]
     
  19. Mac-Michael macrumors regular

    Joined:
    Jan 13, 2010
    #19
    Like so
    Code:
    /bin/mv .bash_profile .broken_bash_profile
    or
    /bin/rm .bash_profile
    But you are right that it is a good idea to specify the full path to the file as well
    Code:
    /bin/mv ~/.bash_profile .broken_bash_profile
    or
    /bin/rm ~/.bash_profile
    ~/ always points to the home directory of the current user
    /bin/rm is remove/delete
     

Share This Page