Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I clicked on terminal.

It shows this:

Last login: Fri Apr  1 17:04:59 on ttys000
-bash: export: /opt/local/bin': not a valid identifier
-bash: export: :/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin':

not a valid identifier Josh@Macbook-Pro~$ export

I installed something yesterday and modified bash_profile. Now I cannot do anything in terminal. Even ls. It returns - Need help. How can I fix it?

bash: ls: No such file or directory
share|improve this question
1  
Don't cross post. Duplicate of apple.stackexchange.com/questions/11219/… –  Wuffers Apr 1 '11 at 23:35
add comment

migrated from stackoverflow.com Apr 1 '11 at 21:59

This question came from our site for professional and enthusiast programmers.

4 Answers

up vote 0 down vote accepted

By the look of that string, it looks like you have messed up your $PATH. Look for the line with the string matching the error it output, and try changing it to:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin

To do this in bash you will probably have to specify the full path for an executable to edit it with, or you could do it with a GUI application. Otherwise, if you have any other shells on your system, try using those and seeing if their $PATH is functioning, and if so you can edit the file as normal through that shell until you get back into bash.

It goes without saying, you should always back up before modifying important files like bash_profile.

share|improve this answer
    
I think it'd be easier to run the export command to temporarily get a working PATH, so he could fix ~/.bash_profile using his favorite text editor. –  lewist Apr 1 '11 at 22:28
add comment

You could try to temporarily use another shell than bash (like zsh).

Go in the Terminal Preferences and click on the Startup tab.

change the "Shells open with" setting to /bin/zsh

Open a new terminal window and there you have a working shell which you can use to edit your bash_profile.

share|improve this answer
add comment

Enable Find to view all hidden files. Since you can't issue any commands from Terminal.app, I think you can either use Onyx (there's an option in Onyx to show hidden files in the Parameters tab), or download a text editor that sees hidden files (eclipse-based IDEs usually see and can open hidden files, or something like TextWrangler or TextMate can do that same).

Navigate to your bash profile through the file system or through the 'open file' dialog of one of those editors and make your changes...

share|improve this answer
add comment

I'm going to assume you know what you modified and you just need a working shell. The easiest way to do that is just boot into single-user mode to make your repairs. To do that, reboot and hold down Command-S until you get to the shell prompt.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.