You can have many ways to install mongodb on linux. But I prefer to install the release from official resource.

Here are my steps to install mongodb 4.0 on ubuntu 18.04 system.

 $ curl -fsSL | sudo apt-key add -

$ echo "deb [ arch=amd64 ] bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

$ sudo apt update

$ sudo apt install mongodb-org

Please note:

  • From my test, ubuntu 18.04 doesn't support the latest mongodb 4.4 version, while 4.0 is supported.
  • mongodb 4.0 doesn't have arm64 architecture, only amd64 available.
  • After installation, mongodb doesn't start up by default, you need to start it by hand.

To start mongodb and enable it as a system service:

 $ sudo systemctl start mongod
$ sudo systemctl enable mongod

You will see this port listening on the system:

 tcp        0      0*               LISTEN      12953/mongod        

Now, let's login into mongodb and issue a query command:

 $ mongo
MongoDB shell version v4.0.28

> show databases
admin 0.000GB
config 0.000GB
local 0.000GB

> use admin
switched to db admin

> show tables

All done.