# MongoDB: bash: mongo: command not found / zsh: command not found: mongo

**Code:** `mongo: command not found (use mongosh)` · **Category:** MongoDB · **Seen on:** MongoDB, Linux

The legacy `mongo` shell was removed from MongoDB 6.0+ installs; the shell is now `mongosh`, or MongoDB isn't installed.

## Meaning

Install the shell separately (`brew install mongosh`, `apt install mongodb-mongosh`, or download), and use `mongosh` instead of `mongo`. For the server use `mongod`. Packages from the MongoDB repo install `mongodb-org-tools` for `mongodump`/`mongorestore`.

## Common causes

- MongoDB 6+ no longer ships `mongo`
- Only mongod installed, no shell
- PATH missing the MongoDB bin directory
- Using a distro package without tools
- Docker image without the shell

## Quick fix

1. Install `mongosh` and run `mongosh "mongodb://localhost:27017"`
2. Add the bin directory to PATH
3. In Docker: `docker exec -it mongo mongosh`

## Detailed fix by platform

### Linux

1. `sudo apt-get install -y mongodb-mongosh` or `brew install mongosh`

## How to diagnose

1. **Version** — MongoDB 6+?
2. **Shell** — mongosh installed?
3. **PATH** — Bin dir?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mongodb/mongo-command-not-found-mongosh)
