28.1. Starting the shell

When used together with a Neo4j server, simply issue the following at the command line:


Under windows, the command is named Neo4jShell.bat.

For the full list of options, see the reference in the Shell manual page.

To connect to a running Neo4j database, use the section called “Read-only mode” for local databases and see the section called “Enabling the shell server” for remote databases.

You need to make sure that the shell jar file is on the classpath when you start up your Neo4j instance.

Enabling the shell server

Shell is enabled by the configuration in conf/neo4j.properties. Here are some sample configurations:

# Enable the remote shell feature
remote_shell_enabled = true

# By default, shell listens only on the loopback interface, but you can specify the IP address of any network interface or use for all interfaces
remote_shell_host =

# The default port is 1337, but you can specify something else if you like
remote_shell_port = 1337

# If you want to be a little protective of your data,
# you can also tell the shell to only support read operations
remote_shell_read_only = true

There are two ways to start the shell, either by connecting to a remote shell server or by pointing it to a Neo4j store path.

Connecting to a shell server

To start the shell and connect to a running server, run:


Alternatively supply -port and -name options depending on how the remote shell server was enabled. Then you’ll get the shell prompt like this:

neo4j-sh (0)$

Pointing the shell to a path

To start the shell by just pointing it to a Neo4j store path you run the shell jar file. Given that the right neo4j-kernel-<version>.jar and jta jar files are in the same path as your neo4j-shell-<version>.jar file you run it with:

$ neo4j-shell -path path/to/neo4j-db

Read-only mode

By issuing the -readonly switch when starting the shell with a store path, changes cannot be made to the database during the session.

$ neo4j-shell -readonly -path path/to/neo4j-db

Run a command and then exit

It is possible to tell the shell to just start, execute a command and then exit. This opens up for uses of background jobs and also handling of huge output of f.ex. an ls command where you then could pipe the output to less or another reader of your choice, or even to a file.

And even to another neo4j-shell, e.g. for importing a dump of another database or cypher result. When used with command mode the shell will not output a welcome message. So some examples of usage:

$ neo4j-shell -c "cd -a 24 && set name Mattias"
$ neo4j-shell -c "trav -r KNOWS" | less

Pass Neo4j configuration options

By setting the -config switch, you can provide a properties file that will be used to configure your Neo4j instance, if started in embedded mode.

$ neo4j-shell -config conf/neo4j.properties -path mydb

Execute a file and then exit

To execute commands from a file and then exit just provide a -file filename. This is faster than piping to the shell which still handles the input as if it was user input.

For example reading a dump file directly from the command line and executing it against the given database. For example:

$ neo4j-shell -file export.cql > result.txt

Supplying - as the filename reads from stdin instead.