Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

migrated from Apr 1 '11 at 21:59

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

Don't cross post. Duplicate of… – Wuffers Apr 1 '11 at 23:35
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. – kate Apr 1 '11 at 22:28

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

Enable Find to view all hidden files. Since you can't issue any commands from, 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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .