The OS X Terminal is an exceptionally useful tool for getting to the underpinnings of OS X and troubleshooting problematic aspects of the system, developing and testing code, and managing remote connections among many other details. When you launch the Terminal, the system should load the default shell in which you can execute various programs and scripts, but depending on how you have configured your system the shell may not load and instead show a blank Terminal window.
There are a couple of possible reasons why this might happen, which are that the default shell configuration for your account may be corrupted, or the Terminal program itself might not be working properly.
- Shell configuration
The default shell for user accounts is the popular Bash shell, which is configured in the Users & Groups system preferences in the Advanced settings for a user. When you load the OS X Terminal utility the program will by default launch this assigned shell, but if there is a problem with the shell's configuration then it may not load. Most shells use hidden files at the root of the user account to save various environmental configurations, startup scripts, and other details, which if corrupt may prevent the shell from starting. For the Bash shell, the configuration files include the following:
.bash_profileUnfortunately if the shell configuration is preventing it from starting up, then you cannot use that shell to edit these files; however, you can have the system use another shell, which can be done in the Terminal program's preferences, where in the Startup section you can set it to open a shell with the default log-in shell (the default setting) or specify a command to load. The command /bin/bash is the command for the default Bash shell, but you can use /bin/sh, /bin/tcsh/, /bin/csh, or any other shell of choice.
With the new shell being used, you should then be able to load the command line and remove or edit the Bash configuration files to restore that shell's functionality.
- Terminal app problem
The Terminal application itself may also be experiencing problems that prevent it from working properly. While the Terminal in essence hosts a shell in which you do your work, the program has a number of features for arranging windows, managing tabs, themes, and other details about interacting with the Terminal. As with any program in OS X, these are saved in the Terminal's preferences file and if there is corruption in this file then the program may experience odd behavior and not display content correctly or perform requested actions.
To fix this issue, as with other programs you can remove the Terminal's preferences file or try restoring one from a backup. To do this, go to the Library in the "Go" menu in the Finder (hold Option in Mountain Lion to reveal the Library in this menu) and open the Preferences folder. In here, locate the file called "com.apple.Terminal.plist" and remove it or invoke Time Machine and restore a version from when the Terminal was working properly.
A final word of note regarding the Terminal: if you are a power user and access the Terminal regularly, then like doubling up on Web browsers to ensure you have access to the Web you might consider having at least one other way to access the command line. Granted you can always boot OS X to Single User mode to gain access to the command line, but doing so within the user account is largely preferred. The Terminal utility in OS X is the default way to do this, but there are several third party options as well. Two that come to mind are the free iTerm 2 emulator and the xterm emulator that comes with the "XQuartz" X11 window system for OS X. With these installed, should something happen to one, then you may be able to use the other to be back up and running with the Terminal.