To install MongoDB on Ubuntu, follow these steps: 1. **Import the MongoDB public GPG Key** MongoDB is signed with a public GPG key to ensure the authenticity of the software. Import this key with the following command: ```bash wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - ``` Replace `4.4` with your desired MongoDB version if needed [2]. 2. **Create a List File for MongoDB** Create the `/etc/apt/sources.list.d/mongodb-org-4.4.list` list file using the echo command: ```bash echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list ``` Again, replace `4.4` with your desired MongoDB version if needed [2]. 3. **Reload Local Package Database** Reload the local package database to include the MongoDB packages: ```bash sudo apt-get update ``` 4. **Install MongoDB Packages** Install the MongoDB packages: ```bash sudo apt-get install -y mongodb-org ``` This command installs the latest stable version of MongoDB [0][2]. 5. **Start MongoDB** Start the MongoDB service: ```bash sudo systemctl start mongod ``` Enable MongoDB to start on boot: ```bash sudo systemctl enable mongod ``` Check the status of the MongoDB service: ```bash sudo systemctl status mongod ``` This should indicate that the service is up and running [2]. If you want to prevent unintended upgrades of MongoDB, you can hold the packages at the current version: ```bash echo "mongodb-org hold" | sudo dpkg --set-selections echo "mongodb-org-server hold" | sudo dpkg --set-selections echo "mongodb-org-shell hold" | sudo dpkg --set-selections echo "mongodb-org-mongos hold" | sudo dpkg --set-selections echo "mongodb-org-tools hold" | sudo dpkg --set-selections ``` This ensures that even when a newer version of MongoDB is available in the repository, it won't be upgraded unless you manually choose to do so [0].