Mac OS X - Terminal window shows up but closes immediately

I'm using Mac OS X Lion 10.7. I open Terminal and its window shows up but immediately close and its icon remains in the dock. It's working fine a moment ago. I don't know what i have messed. I looked at the log file in the Console application and see "login: USER_PROCESS 172 ttys000"


I recently had this issue because I uninstalled the version of bash installed by macports (/opt/local/bin/bash) not realizing it was my default shell. The solution was to change my default shell back to /bin/bash via the advanced user options in the Users & Groups System Preferences. (See @sdmeyers' comment on @Pyrolistical's answer for instructions.)


This looks as if there is an issue with one of the configuration files for your shell. To fix do

  1. With Terminal still running, use Shift-Cmd-N to run zsh
  2. In zsh run ls -l .bashrc .profile and rename all files you found (mv .bashrc .bashrc.save, mv .profile .profile.save)
  3. With the window still open, type Cmd-T to open a new tab running bash.
  4. Assuming this worked, review .bashrc.save/.profile.save (and anything called from there) for errors. You can also rename them back and run login in the running shell which may show some errors from executing the scripts and give you some hints on where to look for problems.
  5. In case running bash in step 3 didn't work (tab closed again) you may also have to rename /etc/profile and /etc/bashrc with sudo mv /etc/profile /etc/profile.save; sudo mv /etc/bashrc /etc/bashrc.save

Try to hide the current ~/.bash_profile from your shell. Just rename it to ~/.bash_profile_bkp and see if something changes.