You will need to install Java if you don't already have it.
$ sudo apt-get update
$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java9-installer
Elasticsearch can be downloaded directly from elastic.co in zip, tar.gz, deb, or rpm packages. For Ubuntu, it's best to use the deb (Debian) package which will install everything you need to run Elasticsearch. Make sure your package list is up to date:
$ sudo apt-get update
Then download the latest elasticsearch package
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.deb
Then install it in the usual Ubuntu way with dpkg.
$ sudo dpkg -i elasticsearch-6.2.4.deb
This results in Elasticsearch being installed in /usr/share/elasticsearch/ with its configuration files placed in /etc/elasticsearch and its init script added in /etc/init.d/elasticsearch. To make sure Elasticsearch starts and stops automatically with the server, add its init script to the default runlevels.
$ sudo systemctl enable elasticsearch.service
And you're done. You can check if the service is running by doing:
$ curl localhost:9200
or
$ service elasticsearch status