Today I was mucking about trying to uninstall macports when I noticed an error being thrown up whenever I used sudo. I killed Terminal and tried to restart it which failed with the error message "You're are not authorized to run this application" and "The administrator has set your shell to an illegal value." How can I fix this?

5 Answers 5


If you are getting some strange error messages in your Terminal windows when they first open, that likely indicates a problem with your Terminal preferences. Try removing (or just renaming) the Terminal preferences file (~/Library/Preferences/com.apple.Terminal.plist) and then restarting the Terminal application. (Source)

If you still have a problem, then look at what you have in your shell dot files: ~/.bash_profile, ~/.bashrc, and the like. If you can’t figure out what the problem is, try removing (or just renaming) those dotfiles.

Another place to look for problems is the default.term file under ~/Library/Application Support/Terminal. This is the file that stores the default settings for Terminal windows.

If all that fails, use Disk Utility to repair the permissions for Terminal. (Source)

  • Thanks for giving a few places to look. I can't confirm if any of them were the cause of my problem because I'd already resolved the issue using Disk Utility to repair permissions but I felt it was a sledge hammer approach and I wanted a better understanding of what went wrong in the 1st place. Mar 31, 2012 at 21:51
  • Neither Terminal application preferences nor any of those files mentioned should be able to affect this particular issue. See my answer for details. Repairing permissions can, though, obviously.
    – Chris Page
    Apr 1, 2012 at 11:00
  • 1
    Why the downvote without leaving a comment explaining it? Especially on an accepted answer. May 3, 2012 at 14:55

…I'd already resolved the issue using Disk Utility to repair permissions…

If repairing permissions clears up the problem, the cause is (almost certainly) that the permissions of /etc/shells were incorrect, preventing Terminal from reading it.

/etc/shells contains a list of valid shell programs, and Terminal checks to see whether the shell for your user account is listed. If not, it produces the “illegal shell” message. If it can’t read the /etc/shells file due to permission issues, it also produces this message.

More rarely, some people have encountered this problem when the /etc/shells file was somehow altered so that it is empty, in which case you’ll need to restore its contents by copying it from a good system, or with a Time Machine restore, etc.

To answer your original question:

If Terminal complains about an “illegal shell” it means that the shell for your user account was not found in /etc/shells.

You can see which shells are considered valid with cat /etc/shells.

You can check which shell your user account is set to use with echo $SHELL, or by reading the user information with dscl . -read "/Users/$LOGNAME" UserShell. Or you can use System Preferences:

  1. Open System Preferences and go to Users & Groups.
  2. Click on the lock and enter your password to be able to read/set user settings.
  3. Control-Click (or Right-Click) on your user to get a contextual menu and choose Advanced Options….

The Advanced Options sheet displays detailed user account information including the shell pathname. You can also use this to edit the shell pathname to re-enable logins if it has been set to a value not listed in /etc/shells.

  • To see why you can't get to a shell, cat /etc/shells. Hmmm
    – wberry
    Jun 9, 2013 at 19:14

I use zsh, while in the settings don't know why $SHELL is set to /usr/local/bin/zsh, then I changed it to /bin/zsh, problem resolved. In my case, repair permissions or other approaches above didn't help. But, thanks anyway.


For me, I received this error because of a chsh typo as well. I use homebrew and (very stupidly) set my shell to the binary in /usr/local/Cellar rather than the dynamic link in /usr/local/bin. As a result Terminal gagged but surprisingly, iTerm did not. This thread was quite helpful for fixing my problem.

To prevent my problem: if you use homebrew, ALWAYS reference the dynamically linked binaries in /usr/local/bin, for these will always be kept up to date.

  • It looks like link did not get attached to the thread you were referencing. Also, when referencing another thread, it would be helpful if you could provide at least a brief overview of the fix in your answer.
    – jbharper2
    Dec 10, 2012 at 3:55

I got the same error after I ran chsh and made a typo in the path for the login shell.

I wasn't able to open Terminal, and nothing happened when I tried to show the advanced options sheet in the Users & Groups preference pane. I was able to run chsh -s /bin/bash in iTerm 2 though.

You can also change the default login shell with dscl or edit /var/db/dslocal/nodes/Default/users/$USER.plist directly.

You must log in to answer this question.

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