Install latest MongoDB in Ubuntu

The MongoDB version available from the default Ubuntu/Debian repositories can be fairly old. Luckily it is easy to get a newer version directly from 10gen repository

# If necessary, remove previous installation
# sudo apt-get remove mongodb
# Add appropriate key
sudo apt-key adv --keyserver --recv 7F0CEB10
# Add Repository to sources.list
echo deb dist 10gen >> /etc/apt/sources.list
# Since we modifed repositofy list we need to run update
sudo apt-get update
# Fetch and install mongodb
sudo apt-get install mongodb-10gen