How to install MongoDB 4.4 on Ubuntu 18?

Connect with

install MongoDB on ubuntuInstall MongoDB 4.4 on Ubuntu Linux 18 is very easy. Here is step-by-step command and you are done. I have done installation on my desktop of Linux Ubuntu 18.

1. Overview of mongoDB installation on Ubuntu linux

You have to follow step by step process for mongoDB installation on Ubuntu Linux. You may though how to install mongoDB 4.4 on ubuntu linux? believe me its super easy, just follow the steps.

2. Import the public key used by the package management system

from the linxu terminal you have to run the following command for importing the MongoDB public GPG Key from from

wget -qO - | sudo apt-key add -


ranjeet@precision-3440:~$ wget -qO - | sudo apt-key add -
[sudo] password for ranjeet: 

if it return OK then do next step else you have to install gnupg in your system and run the following.

sudo apt-get install gnupg

Once installed this then run step #1

3. Create a list file for MongoDB

Create the /etc/apt/sources.list.d/mongodb-org-4.2.list file for Ubuntu 18.0

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


ranjeet@precision-3440:~$ eecho "deb [ arch=amd64,arm64 ] bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

4. Reload local package database

sudo apt-get update

5. Reload local package database

sudo apt-get install -y mongodb-org

output of command as:

ranjeet@precision-3440:~$ sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apt-clone archdetect-deb btrfs-tools dmraid gir1.2-timezonemap-1.0
  gir1.2-xkl-1.0 kpartx kpartx-boot libdebian-installer4 libdmraid1.0.0.rc16
  libido3-0.1-0 libtimezonemap-data libtimezonemap1
  linux-oem-osp1-headers-5.0.0-1043 python3-icu python3-pam rdate
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mongodb-database-tools mongodb-org-database-tools-extra mongodb-org-mongos
  mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
  mongodb-database-tools mongodb-org mongodb-org-database-tools-extra
  mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
0 upgraded, 7 newly installed, 0 to remove and 189 not upgraded.
Need to get 104 MB of archives.
After this operation, 200 MB of additional disk space will be used.
Get:1 bionic/mongodb-org/4.4/multiverse amd64 mongodb-database-tools amd64 100.2.0 [54.4 MB]
Get:2 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org-shell amd64 4.4.1 [13.2 MB]
Get:3 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org-server amd64 4.4.1 [20.3 MB]
Get:4 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org-mongos amd64 4.4.1 [15.7 MB]
Get:5 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org-database-tools-extra amd64 4.4.1 [5,608 B]
Get:6 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org-tools amd64 4.4.1 [2,892 B]
Get:7 bionic/mongodb-org/4.4/multiverse amd64 mongodb-org amd64 4.4.1 [3,520 B]
Fetched 104 MB in 13s (7,736 kB/s)                                             
Selecting previously unselected package mongodb-database-tools.
(Reading database ... 193610 files and directories currently installed.)
Preparing to unpack .../0-mongodb-database-tools_100.2.0_amd64.deb ...
Unpacking mongodb-database-tools (100.2.0) ...
Selecting previously unselected package mongodb-org-shell.
Preparing to unpack .../1-mongodb-org-shell_4.4.1_amd64.deb ...
Unpacking mongodb-org-shell (4.4.1) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../2-mongodb-org-server_4.4.1_amd64.deb ...
Unpacking mongodb-org-server (4.4.1) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../3-mongodb-org-mongos_4.4.1_amd64.deb ...
Unpacking mongodb-org-mongos (4.4.1) ...
Selecting previously unselected package mongodb-org-database-tools-extra.
Preparing to unpack .../4-mongodb-org-database-tools-extra_4.4.1_amd64.deb ...
Unpacking mongodb-org-database-tools-extra (4.4.1) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../5-mongodb-org-tools_4.4.1_amd64.deb ...
Unpacking mongodb-org-tools (4.4.1) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../6-mongodb-org_4.4.1_amd64.deb ...
Unpacking mongodb-org (4.4.1) ...
Setting up mongodb-org-shell (4.4.1) ...
Setting up mongodb-org-database-tools-extra (4.4.1) ...
Setting up mongodb-database-tools (100.2.0) ...
Setting up mongodb-org-mongos (4.4.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up mongodb-org-tools (4.4.1) ...
Setting up mongodb-org-server (4.4.1) ...
Adding system user `mongodb' (UID 123) ...
Adding new user `mongodb' (UID 123) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 128) ...
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Setting up mongodb-org (4.4.1) ...

5. Location of required files

Following are the location of few files which have been created during installation of mongoDB on Ubuntu. You need to know these location because you have to look into time to time for different activities. Data directory are the folder where your actual mongoDB data reside, when you insert any data in mongoDB. log directory are the directory where mongoDB log file reside you need to look into log file time-to-time for any error or tracking etc. and configuration file mongod.config in which you want to change as per your business need. For complete detail in mongod.conf file you can click here mongod.conf

  • Data directory: /var/lib/mongodb
  • log directory: /var/log/mongodb
  • active log file: /var/log/mongodb
  • configuration file: /etc/mongod.conf

5.1 start mongodb

sudo systemctl start mongod
service mongod start

if you received error as: “Failed to start mongod.service: Unit mongod.service not found.”
then run following command

sudo systemctl daemon-reload

5.2 check mongoDB service

following command is used to check whether mongod service is running or not.

sudo systemctl status mongod

If you want to run mongod service on you on boot of Linux then run following command

5.3 to start on boot of system

sudo systemctl enable mongod

5.4 to stop mongoDB

sudo systemctl stop mongod

5.5 To restart mongod service

sudo systemctl restart mongod

5.6 for open a mongoDB shell


How do you feel , is mongoDB installation on ubuntu is easy or tough? please share you experience in comment. You reach to this line, it means you like this article. please share and comment. Happy Learning 🙂

Connect with

1 thought on “How to install MongoDB 4.4 on Ubuntu 18?”

Leave a Comment

Your email address will not be published. Required fields are marked *