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?
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:
~/.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)
…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
You can see which shells are considered valid with
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:
- Open System Preferences and go to Users & Groups.
- Click on the lock and enter your password to be able to read/set user settings.
- 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
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.
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