IMPORTANT: The legacy mongo shell was deprecated in the MongoDB 5.0 release and removed in the 6.0 release packages. The modern replacement is the MongoDB Shell (mongosh) which is a more fully featured JavaScript and Node.js REPL environment that is also compatible with a broader range of MongoDB server versions. For example, as of Feb 2024 mongosh was supporting MongoDB Server v4.2 and greater.

(original answer from March 2019 below)

If you just want the mongo shell, you could install the mongodb-clients package mentioned in your question. However, note that this includes an older shell version (3.6.3).

The official MongoDB packages are updated with each minor release and you should ideally install a shell version matching your MongoDB server's major version (3.6, 4.0). Significant mismatches in shell versus server versions can result in some subtle errors as well as missing or outdated helpers. For example, the MongoDB 3.6.x shell doesn't have helpers for transactions (which were added in 4.0).

The MongoDB documentation includes information on Installing the official packages on Ubuntu. There is a mongodb-org-shell package which only includes the MongoDB shell, and you may also want to install mongodb-org-tools for other command-line tools (mongodump, mongorestore, ...).

It would be best to follow the instructions in the MongoDB documentation as some details may change in future (such as the signing key), but the general steps to follow for MongoDB 4.0 on Ubuntu 18.04 (Bionic) are:

  1. Import the public key used to sign packages from MongoDB, Inc

     sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    
  2. Create a package list file for MongoDB

     echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
    
  3. Update your local package database

     sudo apt-get update
    
  4. Install the desired MongoDB package(s)

     sudo apt-get install -y mongodb-org-shell
    

NOTE: The legacy mongo shell was deprecated in the MongoDB 5.0 release and removed in the 6.0 release packages. The modern replacement is the MongoDB Shell (mongosh) which is a more fully feastured JavaScript and Node.js REPL environment.

Answer from Stennie on askubuntu.com
🌐
Bytebase
bytebase.com › reference › mongodb › how-to › how-to-install-mongodb-shell-on-mac-ubuntu-centos-windows
How to install Mongo Shell (mongosh) on Mac, Ubuntu, CentOS, Windows
MongoDB Shell mongosh is the modern command-line interface for interacting with MongoDB databases. This guide walks you through installing mongosh on Mac, Ubuntu, CentOS, or Windows.
Top answer
1 of 2
38

IMPORTANT: The legacy mongo shell was deprecated in the MongoDB 5.0 release and removed in the 6.0 release packages. The modern replacement is the MongoDB Shell (mongosh) which is a more fully featured JavaScript and Node.js REPL environment that is also compatible with a broader range of MongoDB server versions. For example, as of Feb 2024 mongosh was supporting MongoDB Server v4.2 and greater.

(original answer from March 2019 below)

If you just want the mongo shell, you could install the mongodb-clients package mentioned in your question. However, note that this includes an older shell version (3.6.3).

The official MongoDB packages are updated with each minor release and you should ideally install a shell version matching your MongoDB server's major version (3.6, 4.0). Significant mismatches in shell versus server versions can result in some subtle errors as well as missing or outdated helpers. For example, the MongoDB 3.6.x shell doesn't have helpers for transactions (which were added in 4.0).

The MongoDB documentation includes information on Installing the official packages on Ubuntu. There is a mongodb-org-shell package which only includes the MongoDB shell, and you may also want to install mongodb-org-tools for other command-line tools (mongodump, mongorestore, ...).

It would be best to follow the instructions in the MongoDB documentation as some details may change in future (such as the signing key), but the general steps to follow for MongoDB 4.0 on Ubuntu 18.04 (Bionic) are:

  1. Import the public key used to sign packages from MongoDB, Inc

     sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    
  2. Create a package list file for MongoDB

     echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
    
  3. Update your local package database

     sudo apt-get update
    
  4. Install the desired MongoDB package(s)

     sudo apt-get install -y mongodb-org-shell
    

NOTE: The legacy mongo shell was deprecated in the MongoDB 5.0 release and removed in the 6.0 release packages. The modern replacement is the MongoDB Shell (mongosh) which is a more fully feastured JavaScript and Node.js REPL environment.

2 of 2
5

You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the official website:

The new MongoDB Shell, mongosh, offers numerous advantages over the legacy mongo shell, such as:

  • Improved syntax highlighting.
  • Improved command history.
  • Improved logging.

Currently mongosh supports a subset of the mongo shell methods. Achieving feature parity between mongosh and the mongo shell is an ongoing effort.

To maintain backwards compatibility, the methods that mongosh supports use the same syntax as the corresponding methods in the mongo shell. To see the complete list of methods supported by mongosh, see MongoDB Shell Methods.

Further reference: Compatibility Changes with Legacy mongo Shell

🌐
MongoDB
mongodb.com › try › download › shell
MongoDB Shell Download | MongoDB
MongoDB Shell is the quickest way to connect to (and work with) MongoDB. Easily query data, configure settings, and execute other actions with this modern, extensible command-line interface — replete with syntax highlighting, intelligent ...
🌐
Ubuntu Manpages
manpages.ubuntu.com › manpages › focal › man1 › mongo.1.html
Ubuntu Manpage: mongo - MongoDB Shell
--quiet Silences output from the shell during the connection process. --port <port> Specifies the port where the mongod or mongos instance is listening. Unless specified · mongo connects to mongod instances on port 27017, which is the default mongod port. --host <hostname> specifies the host where the mongod or mongos is running to connect to as <hostname>. By default · mongo will attempt to connect to a MongoDB process running on the localhost.
🌐
Linuxize
linuxize.com › post › how-to-install-mongodb-on-ubuntu-18-04
How to Install MongoDB on Ubuntu 18.04 | Linuxize
July 7, 2020 - To install an older version of MongoDB, replace 4.0 with your preferred version. Update the packages list and install the mongodb-org meta-package by typing: ... mongodb-org-shell - The mongo shell is an interactive JavaScript interface to MongoDB.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-install-and-configure-mongodb-in-ubuntu
How to Install and Configure MongoDB in Ubuntu? - GeeksforGeeks
July 12, 2025 - MongoDB provides a command-line interface called the MongoDB shell, which allows us to interact with the database.
🌐
MongoDB
mongodb.com › docs home › tools › mongodb shell
Install mongosh - mongosh - MongoDB Docs
Prerequisites, compatibility issues, and installation instructions for mongosh, the MongoDB Shell.
Find elsewhere
🌐
Linux Genie
linuxgenie.net › home › how to use mongodb shell on ubuntu 22.04
How to Use MongoDB Shell on Ubuntu 22.04 - Linux Genie
July 9, 2023 - In this guide, we have learned how to install and use the MongoDB Shell on Ubuntu 22.04. We covered the installation process and provided an overview of essential MongoDB Shell commands. Following this guide, you can now interact with MongoDB databases using the command-line interface.
🌐
Cherry Servers
cherryservers.com › home › blog › cloud computing › how to install mongodb on ubuntu 20.04 | step-by-step tutorial
Install MongoDB on Ubuntu 20.04 | Cherry Servers | Cherry Servers
May 9, 2022 - To log in with authentication, first, log out of the Mongo Shell by running the exit command. Then log in using the administrative user using the following syntax. mongosh "mongodb://adminuser@mongo-ip-address:27017"
🌐
ShellHacks
shellhacks.com › home › mongodb: install client – mongo shell – ubuntu, centos
MongoDB: Install Client - Mongo Shell - Ubuntu, CentOS - ShellHacks
October 25, 2018 - Cool Tip: How to connect to remote MongoDB server from the command line using mongo shell! Read More → ... # Ubuntu-18.04: $ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" \ | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list # Ubuntu-16.04: $ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" \ | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list # Ubuntu-14.04: $ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" \ | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
🌐
Hevo Data
hevodata.com › home › blog › database management system
Install MongoDB on Ubuntu: 5 Easy Steps | Hevo
September 12, 2025 - Ubuntu uses the systemd init system, so to start, stop, or check the run status of MongoDB, we use the systemctl command: If you want MongoDB to start automatically each time your system boots, use the systemctl command to “enable” it: Start MongoDB and use the systemctl status command to confirm it is running. If everything is good, you should now be able to connect using the mongosh MongoDB shell:
🌐
LabEx
labex.io › tutorials › mongodb-how-to-install-mongodb-shell-on-linux-435298
How to install MongoDB shell on Linux | LabEx
By following this comprehensive installation guide, you'll successfully set up MongoDB Shell on your Ubuntu 22.04 system, ready for database management and development tasks.
🌐
Skynats
skynats.com › home › how to install mongodb shell on ubuntu
Install MongoDB Shell on Ubuntu – Easy Step-by-Step Guide
1 week ago - MongoDB Shell, commonly known as mongosh, is the modern command-line interface for interacting with MongoDB databases. It replaces the legacy mongo shell and provides improved usability, scripting support, and security features. In this guide, you’ll learn how to install mongosh on Ubuntu ...
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-mongodb-on-ubuntu-20-04
How To Install MongoDB on Ubuntu 20.04 | DigitalOcean
July 31, 2020 - In this tutorial you’ll install MongoDB on an Ubuntu 20.04 server, test it, and learn how to manage it as a systemd service.
🌐
MongoDB
mongodb.com › docs › mongodb-shell
Welcome to MongoDB Shell (mongosh) - mongosh - MongoDB Docs
The MongoDB Shell, mongosh, is a JavaScript and Node.js REPL environment for interacting with MongoDB deployments in Atlas , locally, or on another remote host.
🌐
Hostman
hostman.com › tutorials › how to use the mongodb shell
A Complete Tutorial to MongoDB Shell | Guide by Hostman
2 weeks ago - Comprehensive guide to using the MongoDB Shell. It covers installation, configuration, connection to a MongoDB instance, and performing CRUD operations.
Price   $
Address   1999 Harrison St 1800 9079, 94612, Oakland