Software⏱️ 3 min read📅 2026-06-11

How to Fix: Zsh gives "permission denied" error on iTerm2

Troubleshooting zsh permission denied error in iTerm2 on Yosemite.

Quick Answer: Check if the /usr/local/bin/zsh file has execute permissions and try running zsh with sudo or using a different shell.

The 'permission denied' error in zsh on iTerm2 can be frustrating, especially when you're trying to navigate directories or use shell features. This issue typically affects users who have installed zsh using homebrew and are using the default shell located at /usr/local/bin/zsh.

This problem is particularly annoying because it prevents you from accessing directory contents, which is a fundamental feature of the zsh shell. In this guide, we'll walk you through the root causes of the issue and provide two primary fix methods to resolve the 'permission denied' error in zsh on iTerm2.

🔍 Why This Happens

  • The first main reason why this error happens is due to the lack of ownership or permissions for the /usr/local/bin/zsh file. When you install zsh using homebrew, it creates a symbolic link to the /usr/local/bin/zsh file instead of making it owned by your user account. This can lead to permission issues when trying to run the shell.
  • Alternatively, another reason could be related to the configuration of your iTerm2 application or the shell itself. Sometimes, the shell's permissions or ownership might not match the expected values, resulting in a 'permission denied' error.

✅ Best Solutions to Fix It

Change Ownership and Permissions

  1. Step 1: Open Terminal and run the command `sudo chown -R $(whoami):staff /usr/local/bin/zsh` to change the ownership of the zsh file to your user account. The `whoami` command will display your current username, which should be used in place of `your_username`.
  2. Step 2: Next, run the command `chmod +x /usr/local/bin/zsh` to set the execute permission for the zsh file.
  3. Step 3: After completing these steps, restart iTerm2 or log out and log back in to ensure that the changes take effect.

Change Shell Configuration

  1. Step 1: Open your shell configuration file by running the command `nano ~/.zshrc` (or `nano ~/.bashrc` if you're using bash). Add the following line at the end of the file: `export PATH=$PATH:/usr/local/bin`. This will update the shell's search path to include the /usr/local/bin directory.
  2. Step 2: Save and close the configuration file. Restart iTerm2 or log out and log back in to apply the changes.

💡 Conclusion

To resolve the 'permission denied' error in zsh on iTerm2, you can try either changing the ownership and permissions of the zsh file or updating your shell configuration. By following these steps, you should be able to access directory contents and use other features of the zsh shell without any issues.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions