0

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
1

4 Answers 4

0

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.

1
  • 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, 2011 at 22:28
0

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.

0

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...

0

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.

You must log in to answer this question.

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