In this quick tutorial, you will learn how to install and setup MongoDB on Ubuntu 20.04 Focal Fossa. This guide also applies to Ubuntu derivatives such as Linux Mint, Elementary OS, Pop OS, Zorin, etc.

MongoDB is said to be the most popular database for modern applications. It is a document-oriented database, also known as a NoSQL database. MongoDB uses JSON-like documents with optional schemas.

Being so popular and amazing, it is being used by all kinds of developers, companies, and government organizations.

Now let’s dive into the installation process for MongoDB on Ubuntu or any of its derivatives.

Installing MongoDB on Ubuntu 20.04 Focal Fossa

You can directly install MongoDB from the official Ubuntu repository, however, the available version can be outdated. Here are the steps to get the latest stable MongoDB.

First, you need to get the public PGP key for MongoDB and add it to your system.

wget -qO - | sudo apt-key add -

Next, you need to create a mongodb-org-4.4.list file in the sources.list.d folder. Basically, you are adding a repository link for MongoDB to your system.

echo "deb [ arch=amd64,arm64 ] focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

Use this command to update the packages database for the repositories in your system.

sudo apt-get update

Now, you are ready to install the latest version of MongoDB in your Ubuntu/derivative system.

sudo apt-get install -y mongodb-org

Here the installation process completes. In order to use MongoDB, you have to start the database server.

Running the MongoDB server

In order to use the MongoDB, you have start mongod service. For that issue the below command.

sudo systemctl start mongod

You can also use the service utility.

sudo service mongod start

To check the status of MongoDB use this command.

sudo service mongod status

To stop MongoDB service.

sudo service mongod stop

Watch Video guide on YouTube

Additionally, You can also watch a step-by-step video guide on YouTube to get a better understanding of it.


So that’s the tutorial on how to install the latest MongoDB on Ubuntu 20.04 Focal Fossa. Let me know what you think about it in the comments and subscribe to the LinuxH2O Youtube channel. Till then, keep enjoying Linux.