1) Initially import the public key used by the package:
2) Then create a list file using the command appropriate for your version of Ubuntu:
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
3) Once you're done with the above command reload the local package database:
sudo apt-get update
4) Creating the systemd service file for mongodb:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
5) Once you have successfully come across all the above steps, start the daemon service:
sudo service mongod start
6) Check whether the service has started successfully from the mongodb logs. These logs would normally be stored in "var/log/mongodb". You should be able to see the following line, if there aren't any errors:
[initandlisten] waiting for connections on port <port>
In the above, port resembles the listening port.
7) Stopping the service:
sudo service mongod stop
8) Restarting the service:
sudo service mongod restart