zsh command not found (2023)

If you came across the annoying “zsh command not found” error then worry not, we got you covered. In this article, we are going to see how you can resolve this error in multiple ways.

Before we start, know that we will be discussing how to fix the error on macOS and Linux. So if you are getting errors on other platforms or languages like python, please check other discussion blogs.

Table of Content

  • 1 How to Fix “Zsh command not found” error in Linux or macOS
  • 2 Why you should use “zsh” instead of “bash” shell?
  • 3 Check whether “command is valid” to avoid zsh command not found error
  • 4 Check if the command is not misspelled (if you are getting the zsh command not found error)
  • 5 “Package is installed” can help in fixing the zsh command and not found error
  • 6 Check “$PATH” Environment variable is correctly set to fix the “zsh: command was not found error
  • 7 Setup the command path in the .zshrc file to fix the “zsh: command not found” error
  • 8 Summary
  • 9 FAQ – zsh: command not found error

How to Fix “Zsh command not found” error in Linux or macOS

If you are getting a “zsh command not found” error on your macOS or Linux machine, then it can be hard going through all the discussion blogs to find the solution. So we went through all those decisions and got the tried and tested solutions.

Now these are the most common reasons for getting the error and you can save time by identifying it first:

  • The command you are trying to execute may be invalid.
  • Maybe the path environment is not setup for the package
  • The command is valid but the package is not installed on your device.
  • The command may have typo or maybe misspelled
  • The command path is not set up on your device (.zshrc file)

If none of the above-mentioned reasons ring a bell, then check these errors you can get when using the Z shell (zsh) on Linux, macOS, or Unix:

  • zsh command not found docker
  • zsh command not found npm
  • zsh command not found node
  • And more

Now in the solutions, we are going to see, it will not matter which of the above-mentioned error you got. We will see all the possible solutions for “zsh: command not found”. We will suggest you go through all the solutions one by one since we will see easy to hard difficulties.

zsh command not found (1)

Why you should use “zsh” instead of “bash” shell?

You need to change the default “bash” to “zsh” if you want to use use features like automatic CD, theme correction, recursive path, and more. Here, zsh stands for “Z shell” and bash stand for “Bourne Again Shell”.

NOTE: If you are using the Linux distro, then bash will be installed by default.

Now, if you want to install zsh on your Ubuntu or macOS, then use the following command or use an online guide:

$ sudo apt install zsh

(Video) zsh:command not found:code

If you want to download package information, then you can use the update command. “Sudo apt-get update” will download package info for all the configured sources.

Now, when you will run the above mentioned command, the package information will be downloaded. This is very useful when you want to get the information on packages or their dependencies (updated version).

sudo apt-get update

sudo apt-get install zsh

After using the above mentioned commands, the ZSH shell will be installed on your device. But if you want to check if ZSH is working, then you can use the below mentioned command.

zsh –version

Check whether “command is valid” to avoid zsh command not found error

If you are getting the error “command not found” on macOS, Unix, or Linux. Then you should first check if the entered command is valid and does not contain any typo. In most cases, there may be a typo which is causing the error. You can check if the command is valid or not by using below mentioned command.

dev-ubuntu-2104% cls (trying to run this cls command)

Zsh: command not found: cls (getting error output)

We are getting errors here because the screen in Linux is clear and NOT cls. This is why it’s very important to check if the syntax and the command are correct before we look for solutions everywhere.

Check if the command is not misspelled (if you are getting the zsh command not found error)

Another very common mistake people generally make is not checking spelling and spending hours looking for a solution. And finding out later that you made a simple typo is very frustrating. For example, if you try executing “nestat” then you will get the error “zsh command not found”. Here you should have been using “netstat” in the first place and check if it’s a typo.

(Video) How to fix zsh command not found flutter (100% Resolved)

So, before you look for the solution everywhere, check if it’s a typo or not.

“Package is installed” can help in fixing the zsh command and not found error

Sometimes we can run commands and not check if the package is installed on our device or not. This can happen if you regularly use a different device and try to run commands on a new device.

Now, if you are sure that it’s not a typo issue then for example we can run the “npm” command in Ubuntu.

dev-ubuntu-2104% npm

zsh: command not found: npm

This error came because the npm package was not installed on the device with Ubuntu. Now to solve this, we need to install the npm package on our device and run the command again. Use the command below to install npm:

dev-ubuntu-2104% sudo apt install npm

Check “$PATH” Environment variable is correctly set to fix the “zsh: command was not found error

If you have checked that package is installed and there is no typo and error is still coming, then we can move forward.

Another reason for the error can be the invalid or missing PATH variable on your device. For any package, the PATH variable should be set up since many time the PATH may not set up automatically.

Now, for most packages, the path variable is set automatically during the initial installation. But in some cases, maybe due to custom installation, the path variable did not set up and not causing issues. We can take example of maven package, you can run the “mvn” command to check if it’s installed.

See also com.android.carrierconfig: What is com android carrierconfig

dev-ubuntu-2104% maven (command)

(Video) zsh: command not found: python

zsh: command not found: mvp (output)

This error came because the $PATH in the environment variable or Linux needs to be set up manually. You can try to install the Maven or another package again and see if it solved the issue. But settings the path variable manually is more effective.

Use the following steps for your Linux system, we will be taking examples of Maven commands. Now, the maven commands are in “/opt/apache-maven-3.0.0/bin”.

Replace it with, dev-ubuntu-2104% export

PATH=$PATH:/opt/apache-maven-3.2.0/bin

Use the following steps for the Windows system, add the path of your package (maven) in the bin directory to the system variable path. For example, the system path variable for Apache software will be:

C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.0.0\bin.

Check the path variable is set up correctly, in most cases it’s causing the issue. And it can save hours of reading discussion blogs and constant reinstallation.

Setup the command path in the .zshrc file to fix the “zsh: command not found” error

Now, if you checked that there’s no typo, the package is also installed and the path variable is set. Then the only other cause of this error is the terminal itself. Try exiting and re-login the terminal, you should try again. If you again get “zsh command not found”, then it means that for .zshrc file the command path is not set up properly. In this case, you should set up the command path.

If the file does not exist, then we need to create a new “.zshrc” file, we can do this by the “touch ~/.zshrc” command. Now, exit and reopen the terminal and the file will execute and set up automatically. Follow these steps to edit the created file:

  1. On your macOS or Linux device, open the terminal with Commad + space for macOS, and Ctrl + Alt + T for Linux.
  2. Now check if you are on zsh shell or not, if not then change it. If you are on zsh shell, type “zsh” and hit enter.
  3. Once done, type “nano ~/.zshrc” and now add the $PATH variable details for your device like “export PATH=$PATH:/opt/apache-maven-3.0.0/bin/”.
  4. Now press “Ctrl + X” or “Control + X”, followed by “Y” and this will save the file. You can press enter to exit the nano editor.
  5. Once you have completed all the previous steps, then type “sourse ~/.zshrc” to commit all the changes.

Read Also: How to Fix Kmode Exception Not Handled Error

Summary

In the article, we saw why you may be getting the error and what are the most common sources of error. Along with it, we also saw some of the tried and tested solutions that will most definitely solve your issue. But if it’s still not solved then try checking StackOverflow or other discussion blogs which may contain solutions that work for you.

The best way to fix any error is to trace it back to its source and isolate the source. We would suggest you check if you have everything needed to run the command and if the command is correct. Sometimes, we can miss little things like typos and then scratch our heads all day.

See also Disney Plus APK
(Video) ✅ Solved ✅ How To Fix Homebrew Installation Problem Zsh Command Not Found - Brew | M1- Intel Macbook

But if you want help with any of your tech issues, then feel free to drop it down in the comment section below. We are more than happy to help out our readers.

Now, your issue should be solved and now you can sit back and get your work done. But if your issue is not solved, check the FAQ section since it can help you get a better idea. Or you can go thought discussion blogs or StackOverflow and see if anyone got an answer that works for you.

FAQ – zsh: command not found error

In this section, we will answer some of the commonly asked questions which are related to the zsh command not found error.

How do I fix the “zsh: command not found brew” error on macOS

Now, we need to check if brew is installed on your device along with the PATH variable set up. If you have already installed brew, then you can skip initial steps.
Now, follow the steps to fix the error:
Open the terminal on your macOS device and make sure that you are using the zsh prompt. If not then type “zsh” and hit enter.
Once done, type this command “/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”, this will install brew.
Now, set the path variable by using the following command, this will be suggested by the installation wizard also. Type,
echo ‘eval $(/opt/homebrew/bin/brew shellenv)’ >> /Users/$USER/.zprofile
Once done, run the following command by hitting enter on your keyboard.
eval $(/opt/homebrew/bin/brew shellenv)
Now, run the brew help command to check if the installation was successful and validate it.
If you find that the brew which you installed is not working, use the “.zshrc” file and run the below mentioned command in it.
export PATH=/opt/homebrew/bin:$PATH
Now run this command to implement the changes.
% source ~/.zshrc

How to fix the “zsh command not found code” error in macOS?

Before we can start, make sure that you have already installed Visual Studio Code on your macOS device as per the instructions provided here. Now, if you are getting error when laughing code, follow these steps:
For bash shell users, copy and paste the command mentioned below in the terminal:
cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH=”\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin” EOF
For macOS devices, make sure you are using zsh and enter the following command in the terminal:
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code)
export PATH=”\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin” EOF

How do I solve the “zsh command not found docker” error on macOS?

(Video) How to solve the homebrew installation problem "Zsh: command not found - brew"

If you are facing this issue, then it occurs if you do not follow the right instructions while docker installation. You need to install it again and follow all the steps mentioned on docker.com. Check the site once and validate all the installation steps you took.

More Gossipfunda Tips

  • Pokemon go GPS signal not found
  • Module not found error Python | ModuleNotFoundError
  • Command prompt for android
  • BSCedit command: Solution for Bad System Config Info
  • command "python setup.py egg_info" failed with error code 1

FAQs

Does Homebrew work on zsh? ›

Homebrew comes with completion definitions for the brew command. Some packages also provide completion definitions for their own programs. zsh , bash and fish are currently supported.

How do I open a .zshrc file on a Mac? ›

If you now exit from the Terminal and then open a new window, the ~/. zshrc settings should now be loaded in. With the latest Mac BigSur . zshrc file comes as a default.
...
Steps for creation:
  1. Open Terminal.
  2. Type touch ~/. zshrc to create the respective file. ( touch command will create the . ...
  3. Hit Return.

How do I install homebrew on my Mac? ›

How to install Homebrew on Mac
  1. Step 1: Install command line tools for Xcode. Xcode is Apple's native IDE, an integrated development environment that has all the tools you need for software development on Mac. ...
  2. Step 2: Install Homebrew on Mac. ...
  3. Step 3: Turn off analytics. ...
  4. Step 4: Set up Homebrew. ...
  5. Step 5: Update Mac Homebrew.
15 Aug 2022

How do I reinstall zsh on my Mac? ›

Getting Started With ZSH for MacOS
  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. brew install --cask iterm2.
  3. brew install zsh.
  4. brew list.
  5. cd /etc.
  6. ls.
  7. vi ~/.zshrc.
  8. ZSH_THEME=”powerlevel10k/powerlevel10k”

How do I install zsh? ›

How to install zsh on many platforms
  1. sudo port install zsh zsh-completions. Ubuntu, Debian & derivatives (Windows 10 WSL | Native Linux kernel with Windows 10 build 1903)
  2. zypper install zsh. ...
  3. pacman -S zsh. ...
  4. xbps-install zsh. ...
  5. dnf install zsh. ...
  6. pkg_add zsh. ...
  7. sudo yum update && sudo yum -y install zsh. ...
  8. eopkg it zsh.
5 Jun 2022

Should I use Bash or zsh on Mac? ›

The Z shell (also known as zsh ) is a Unix shell that is built on top of bash (the default shell for macOS) with additional features. It's recommended to use zsh over bash . It's also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.

Is zsh better than Bash? ›

Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.

Why did Apple go to zsh? ›

One of the primary reasons why Apple switched to zsh is because it is closer to the functionality of the standard bash. If you are familiar with the standard bash, you will be glad to know that there is an Apple ZSH prompts which looks similar to the one you will find in Microsoft Outlook.

Does macOs come with zsh? ›

The default shell is zsh. You can change the shell that new Terminal windows and tabs open with.

Where is the zsh file on Mac? ›

zshrc file on a Mac? The . zshrc file will be located in the users home directory, or ~/, and this user . zshrc file is where you'd place customizations to the z shell.

Where is zsh on Mac? ›

Step 3: Install ZSH

Zsh is a shell designed for interactive use, although it is also a powerful scripting language. By default, macOs ships with zsh located in /bin/zsh . Let's install zsh using brew and make iTerm2 use it.

Is there an alternative to Homebrew on Mac? ›

Nix, pip, npm, Anaconda, and Chocolatey are the most popular alternatives and competitors to Homebrew.

Why is brew not found on Mac? ›

The “brew command not found” error occurs when your system cannot find the brew binary in its path. Unix systems have a list of directories in which to check for binaries of a command. Therefore, when you run a command from your terminal, the system will search this list of directories for the binary with that name.

What is the purpose of Homebrew for macOS? ›

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste.

Is zsh installed by default on Mac? ›

Every new Mac uses the Z shell (Zsh) by default, but you can quickly and easily switch the default shell back to Bash. There are several reasons you might want to do this. For example, you may need to be using the bash shell to execute bash scripts on a Mac.

Where is zsh installed? ›

oh-my-zsh directory. At installation, it resides at the base of your home directory, but modern Linux convention, as defined by the Free Desktop specification, is to place directories that extend the functionality of applications in the ~/. local/share directory.

How do I start zsh? ›

Getting Started with the Zsh Shell
  1. Install Zsh Shell – MacOS. ...
  2. Install Oh My Zsh. ...
  3. Install Zsh – Ubuntu on WSL 2. ...
  4. Install Oh My Zsh. ...
  5. Add Fonts. ...
  6. Install the Powerline Fonts – MacOS git clone https://github.com/powerline/fonts.git cd fonts ./install.sh. ...
  7. Install the Powerline Fonts – Windows. ...
  8. Ligatures.
30 Dec 2020

Why is it called zsh? ›

The name zsh derives from the name of Yale professor Zhong Shao (then a teaching assistant at Princeton University) – Paul Falstad regarded Shao's login-id, "zsh", as a good name for a shell. Zsh was at first intended to be a subset of csh for the Commodore Amiga, but expanded far beyond that.

Is zsh on Linux? ›

You probably already know that there are various shells available in Linux/Unix. Bash is the most popular and the default shell on most Linux distributions. Another popular shell is Zsh. It is powerful and it is also the default Shell in macOS.

What does zsh stand for? ›

Z-shell (or Zsh) is an interactive Bourne-like POSIX shell known for its abundance of innovative features. Z-Shell users often cite its many conveniences and credit it for increased efficiency and extensive customization.

Does Mac Big Sur use bash or zsh? ›

For a long time, the bash was a default shell in macOS. However, Apple replaced Bourne Again SHell with Z shell for licensing reasons. This page explains how to set up bash as your default login shell and interactive shell on macOS Catalina, “Big Sur” and above.

How do I change from bash to zsh on Mac? ›

The default shell is zsh. You can change the shell that new Terminal windows and tabs open with. In the Terminal app on your Mac, choose Terminal > Settings, then click General. Next to “Shells open with”, select “Command (complete path)”, then enter the complete path to the shell you want to use.

Why You Should Use zsh? ›

zsh-you-should-use provides a convenience function check_alias_usage which you can run to analyse your alias usage. check_alias_usage analyses your history to generate this data for you.

Why should I use zsh over bash? ›

Zsh is built on top of bash thus it has additional features. Zsh is the default shell for macOS and Kali Linux. Zsh provides the user with more flexibility by providing various features such as plug-in support, better customization, theme support, spelling correction, etc.

Is zsh good for beginners? ›

Easy Customization

The customization options are what really sets Zsh apart from the other shell programs for beginners. When you have the shell configured to your liking, it is easy to navigate. And when you set it up with helpful plugins, you can add to your productivity.

Is zsh and bash different? ›

Bash sets the prompt from PS1 which contains backslash escapes like \a whereas zsh contains the percent escapes like %d . The functionality of bash PROMT_COMMAND is available in zsh via precmd . Zsh also offers ways to do fancy customizations.

How do I reset my Mac Terminal? ›

To Reset and Clear your Terminal: Press the menu button in the top-right corner of the window and select Advanced ▸ Reset and Clear.

Can Windows run zsh? ›

There are 2 options to install zsh on Windows. We can either install zsh on WSL or replace the git bash shell with zsh. See Git Bash vs WSL.

When did Mac switch to zsh? ›

Apple has announced that in macOS 10.15 Catalina the default shell will be zsh.

How do I reset my zsh config? ›

To reset your zsh settings to default, just delete your . zshrc file by clicking it once and then pressing ⌘ ⌫ (Cmd-Backspace). (If you see any other . To try to fix the problem without losing your config, edit your .

What is the default zsh prompt? ›

If you are running ZSH for the first time, a prompt will ask you to configure the . zshrc configuration. You can select the default configuration by pressing 2. If you haven't done any ZSH configuration, the prompt will be in the form of username@hostname, the current working directory, and then the prompt symbol.

Will Homebrew damage my Mac? ›

Software is largely the same whether you install it from the command line or the Mac App Store. Homebrew as a distribution mechanism is perfectly safe and open source.

Can I code for iOS without a Mac? ›

You cannot develop iOS apps without a Mac computer, but you can set up CI/CD to handle building and publishing!

How can I make my Mac more like Windows for free? ›

5 Apps You Can Use to Make Your Mac Look Like Windows
  1. Get the Windows Taskbar With uBar. ...
  2. Customize Your Dock With ActiveDock. ...
  3. Add More Features to Finder With XtraFinder. ...
  4. Resize Windows on Your Mac With BetterSnapTool. ...
  5. Change Your Shortcut Keys With Witch.
27 Oct 2022

How do I enable kernel on my Mac? ›

Grant access to the kernel extension
  1. Open Apple System Preferences.
  2. Open Security & Privacy.
  3. Select the General tab.
  4. If general settings are locked: Click the lock icon in the lower-left corner. Enter your device password. Click Unlock.
  5. Click Allow next to kernel extension that requires approval.
15 Nov 2021

Is Brew supported on M1 Mac? ›

If you're coming to M1 Mac fresh, without any old projects or profiles, you probably won't notice; Homebrew will work as it always has. But if you're trying to migrate from an Intel Mac you won't be able to just move packages that were once in /usr/local over to /opt/homebrew .

Why do developers use Mac instead of Windows? ›

The Operating System: macOS vs Windows

macOS is built on top of Unix. This makes Mac computers developer-friendly because most web and database servers are based on Unix. On Windows, you can get a similar experience with the PowerShell, but it won't be the same. Another benefit of macOS is security.

Why do I need Rosetta on my Mac? ›

Rosetta 2 enables a Mac with Apple silicon to use apps built for a Mac with an Intel processor.

Do you need virus for Mac? ›

In short, yes, you do need antivirus for your Mac. Mac computers are not immune to viruses, and other malware and Mac-targeted attacks are increasingly prevalent. Following best practices for securing your device and using built-in security features can help, but antivirus software can protect your device even further.

Where can I find zsh on Mac? ›

zshrc file on a Mac? The . zshrc file will be located in the users home directory, or ~/, and this user . zshrc file is where you'd place customizations to the z shell.

How do I reset my Mac terminal? ›

To Reset and Clear your Terminal: Press the menu button in the top-right corner of the window and select Advanced ▸ Reset and Clear.

Why does Apple use zsh? ›

One of the primary reasons why Apple switched to zsh is because it is closer to the functionality of the standard bash. If you are familiar with the standard bash, you will be glad to know that there is an Apple ZSH prompts which looks similar to the one you will find in Microsoft Outlook.

Is zsh and Bash same? ›

Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.

How do I know if my Mac is bash or zsh? ›

Alternative. Update your Terminal preferences to open the shell with the command /bin/bash , as shown in the screenshot above. Quit and restart Terminal. You should see “hello from bash”, but if you run echo $SHELL , you will see /bin/zsh .

What is difference between zsh and bash in Mac? ›

Bash doesn't have an inline wildcard expansion. Zsh has a built-in wildcard expansion. Doesn't have customization options. Zsh has many frameworks that provide customization.

What is zsh stand for? ›

The Z-Shell, `zsh' for short, is a command interpreter for UNIX systems, or in UNIX jargon, a `shell', because it wraps around the commands you use.

Is zsh a Linux command? ›

The ZSH or Z Shell is a Unix based shell or can be called as a command-line interpreter. It is an extended version of the good old Bourne shell (sh). It does have some features form Bash with lots of added features like automatic cd (Change Directory), spell check, path expansion, and many more.

What is zsh Mac? ›

The Z shell (also known as zsh ) is a Unix shell that is built on top of bash (the default shell for macOS) with additional features. It's recommended to use zsh over bash . It's also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.

How do you do a master reset on a Mac? ›

From the Apple menu  in the corner of your screen, choose System Settings. Click General in the sidebar. Click Transfer or Reset on the right. Click Erase All Content and Settings.

What is hard reset in Mac terminal? ›

Follow these steps to reset it:
  1. Open Mac terminal.
  2. Click "shell", it's on the task bar at the top of the screen.
  3. Navigate to "New Command" or press the keys shift + command + N.
  4. Type mv . bashrc . bashrc. bak redo the same thing for . bash_profile.
  5. Now restart your terminal. It should work fine!
14 Nov 2021

Videos

1. Flutter : zsh command not found | 100% Resolved | Permanent path fix !!!| Subtitles | flutter coding
(amplifyabhi coding)
2. Install MySql server on zsh shell | zsh: command not found: mysql (Fixed) on Macbook M1 / M2
(CodeWithArjun)
3. Mac: Terminal (zsh) command not found
(Roel Van de Paar)
4. How to fix bash_profile/PATH not working in OS X Catalina Terminal by using zshrc instead
(Jonathan Soma)
5. zsh: command not found: php macOS Terminal error | How to fix
(Coffee Programmer)
6. macOS Terminal (zsh) - The Beginners' Guide
(Academind)
Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated: 02/04/2023

Views: 6156

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.