You can install MongoDB on Ubuntu by following these steps:
Open a terminal window.
Import the MongoDB public GPG key by running the following command:
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Create a MongoDB source list file by running the following command:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Note that the above command is for Ubuntu 20.04 (Focal Fossa). If you are using a different version of Ubuntu, you should replace “focal” in the command with the appropriate codename for your version.
Update the package list by running the following command:
sudo apt-get update
Install MongoDB by running the following command:
sudo apt-get install -y mongodb-org
Once the installation is complete, MongoDB should be automatically started. However, you can check its status by running:
sudo systemctl status mongod
This should show that MongoDB is active and running.
That’s it! MongoDB should now be installed and running on your Ubuntu system.