Mongodb: the Mongo Shell & Basic Commands

This article is about the default client for MongoDB: the MongoDB Mongo shell. In this article, we’ll:

(This article is part of our MongoDB Guide. Use the right-hand menu to navigate.)

What is the MongoDB Mongo shell?

MongoDB Mongo shell is an interactive JavaScript interface that allows you to interact with MongoDB instances through the command line. The shell can be used for:

  • Data manipulation
  • Administrative operations such as maintenance of database instances

MongoDB Mongo shell features

MongoDB Mongo shell is the default client for the MongoDB database server. It’s a command-line interface (CLI), where the input and output are all console-based. The Mongo shell is a good tool to manipulate small sets of data.

Here are the top features that Mongo shell offers:

  • Run all MongoDB queries from the Mongo shell.
  • Manipulate data and perform administration operations.
  • Mongo shell uses JavaScript and a related API to issue commands.
  • See previous commands in the mongo shell with up and down arrow keys.
  • View possible command completions using the tab button after partially entering a command.
  • Print error messages, so you know what went wrong with your commands.

MongoDB has recently introduced a new mongo shell known as mongosh. It has some additional features, such as extensibility and embeddability—that is, the ability to use it inside other products such as VS Code.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article