ref – https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04
Step 1 — Installing MongoDB
Ubuntu’s official package repositories include an up-to-date version of MongoDB, which means we can install the necessary packages using apt.
First, update the packages list to have the most recent version of the repository listings:
sudo apt update
Now install the MongoDB package itself:
sudo apt install -y mongodb
This command installs several packages containing the latest stable version of MongoDB, along with helpful management tools for the MongoDB server. The database server is automatically started after installation.
Next, let’s verify that the server is running and works correctly.
Step 2 — Checking the Service and Database
The installation process started MongoDB automatically, but let’s verify that the service is started and that the database is working.
First, check the service’s status:
sudo systemctl status mongodb