How to install and use Neo4j on Ubuntu

The database management system is a very useful and widely used tool among several organizations that work on computing platforms. The data inside traditional databases are saved in a tabular-like structure. However, another trending type of database named graph database is committed to handling the relations between data graphically; some examples of graph databases are Neo4j, ArangoDB, OrientDB, and FlockDB. Among the above-listed graph databases, Neo4j has emerged as a handy graph database management system since its deployment in the industry back in 2007. With an extensive range of features, Neo4j offers two versions and is named as community edition and enterprise edition. Community edition operates on an open-source license and includes basic features of the database like full-text search, data types. Contrary to this, the enterprise edition contains some advanced features for the customers that pay for the subscription; the extra features include auto cache reheating, faster and restorable, etc.

How Neo4j is better than traditional Databases

Unlike other traditional databases, Neo4j has a completely flexible structure as it saves the relationships that connect your data; each node contains a direct pointer to other nodes. Other databases do not save relationship data directly, they can figure out connections, but they usually do this by searching around data structures with the help of indexing that is more expensive in some cases and a time-consuming step too. The prominent uses of Neo4J are fraud detection, real-time recommendation engines, network, and IT operations, etc. As the native storage mechanism of Neo4j is based on these graphical presentations that make this database distinctive from other traditional ones like SQL types of databases. This is the reason that most enterprises like NASA, CISCO, hp, and many more have preferred Neo4j over traditional databases.

Keeping an eye on the importance of Neo4j, we have compiled a guide that addresses step by step procedure of installing Neo4j on your Ubuntu.

How to install Neo4j on Ubuntu

This section comprises the steps that are mandatory to install Neo4j on Ubuntu; follow the steps carefully to get the required program on your system:

Step 1: Firstly, update the packages list by executing the following command in the terminal:

$ sudo apt update

Step 2: The second step is performed here to add a package for HTTPS connections, and if this package uses a library named libapt-pkg to enable HTTPS. However, if the package is already available, then the following command will update that package, so it is beneficial in both regards. apt-transport-https

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step 3: After this, you must add the GPG key to verify that the installation is being performed using a safe and secure manner. So, to add a GPG key or Neo4j, copy and paste the following command in terminal to do so:

$ sudo curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -

Step 4: Add repository of Neo4j to package manager list by using the below-mentioned command:

$ sudo add-apt-repository “deb https://debian.neo4j.com stable 4.1

Step 5: Finally, you are up to installing Neo4j on your system; it is noticed that if you have not installed Java packages prior to this installation, then the command below will ask you to press y to install all dependencies, including Java packages (that are required for this installation). However, if you have already installed the Java packages, you will not get any prompt during installation, and your installation will be completed in a single go: so, execute the following command in terminal to install Neo4j:

$ sudo apt install neo4j

How to check and enable the Neo4J service

After installation, you can check the status of the Neo4j service by executing the following command, and you can see the service is active in our case:

$ sudo systemctl status neo4j.service

If you want to disable the service, you will have to execute the command mentioned below: after that, when you will check the status of the Neo4j, it will show as dead:

$ sudo systemctl stop neo4j.service

If the service is disabled, you can make active the status of the Neo4j service with the help of the command mentioned below, and it is observed that the status will turn to active:

$ sudo systemctl start neo4j.service

How to remove Neo4j from Ubuntu

The installed version can be removed by executing the following command in your terminal:

$ sudo apt autoremove neo4j

How to use Neo4j on Ubuntu

This section will guide you to use this service on our Ubuntu operating system.

Once you have installed the service, make sure the service is active and in running state by using the following command:

$ sudo systemctl status neo4j.service

After that, go to your browser address bar and run the following address to run this service: the time you run the following address, you will notice that it will ask you to fill the information and connect to Neo4j:

For instance, I have used the following information to connect to the service:

Username: neo4j
Password: neo4j

After inserting the information, click on “Connect” to continue:

In the next step, this service will ask you to choose a new password and then click on “Change Password” to continue:

After configuring the above steps, the connection will be made successfully; the main window contains the “Query bar,” and on the left pan of this window, several options are present to guide/help the new users:

Navigate to the query bar to create a new database; For instance, we have created a new database, “linuxhint” that contains the message “Hello World!” and the query for this is written below: Once you have written this query, click on the “play” button to execute it;

CREATE (DATABASE:DATABASE {name:"linuxhint"})-[r:SAYS]->(message:Message {name:"Hello World!"}) RETURN DATABASE, message, r

You will see the database “linuxhint” says “Hello World!”, moreover, the database is shown in an orange-colored circle, whereas the message is displayed in a blue shaded circle:

This would be helpful for the new users, and the advanced users can also polish their skills by manipulating complex data.


Neo4j is a kind of database that relates to the graphical databases family, and it offers enterprise and community editions. The performance efficiency of Neo4j forced several well-known enterprises to switch their system from traditional databases to Neo4j. Knowing the importance of this graph database, we have compiled a detailed guide to list down the steps to install this useful service on Ubuntu and briefly described the use of the Neo4j service on Ubuntu.

About the author

Adnan Shabbir