How to install Elasticsearch on Ubuntu

Elasticsearch is a popular search and analytics engine that can be used for a variety of applications including endpoint security and AI/ML research.

See how you can install Elasticsearch on your Ubuntu system in a few easy steps!

Prerequisites for installing Elasticsearch

How to install Elasticsearch on Ubuntu Picture 1

There is an important prerequisite for installing Elasticsearch on Ubuntu. Since Elasticsearch is a Java application, you will need to properly install and configure JDK version 11 or later on your system.

Here is how to check if JDK is installed on Linux:

java --version

This command will output the version of Java installed on your system. In case you get "command not found" message or any other kind of error, it probably means you don't have Java installed.

You can manually install the JDK by downloading the tarball or install it through the Linux distribution's package manager. Ideally install via the package manager, as it's faster and not as much hassle as the previous method.

This is how you can install JDK on Ubuntu using APT package manager:

sudo apt install openjdk-18-jdk 

You can replace 18 in the command with any JDK version higher than 11. Wait for the installation to finish and then run the command again to check the Java version. This time around you will see the version as output.


How to install Elasticsearch on Ubuntu

Step 1: Add the GPG key and update the repository

Elasticsearch is not part of the official Ubuntu repositories. To install Elasticsearch using APT, you need to add its source list and GPG key.

Run the following commands to add the Elasticsearch package source and GPG key, and update the source list for APT:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list sudo apt update

Note : You can change the "8" in the second command to "7" or some other version in case you want to download a specific version of Elasticsearch.

Step 2: Install Elasticsearch with APT

How to install Elasticsearch on Ubuntu Picture 2

Now you can install the Elasticsearch package with APT like you would install any regular package. Here is the command to install Elasticsearch on Ubuntu:

sudo apt install elasticsearch

Enter Y when prompted for permission and wait for the installation to finish. Once installed, follow the steps that appear on the screen to configure Elasticsearch to integrate with Kibana or other data visualization software.

Step 3: Install Elasticsearch using DEB . package

In case you don't want to use APT to install Elasticsearch, you have the option to download the DEB package provided on the official website and install it using the dpkg command.


First, download the DEB package using wget. Then use the dpkg command with admin rights to install Elasticsearch:

wget sudo dpkg -i elasticsearch-8.8.2-amd64.deb

Keep in mind that you may need to modify the command to match the version of Elasticsearch you want to install.