31.1. Starting the shell

31.1.1. Enabling the shell server
31.1.2. Connecting to a shell server
31.1.3. Pointing the shell to a path
31.1.4. Read-only mode
31.1.5. Run a command and then exit

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


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

To connect to a running Neo4j database, use Section 31.1.4, “Read-only mode” for local databases and see Section 31.1.1, “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.

31.1.1. Enabling the shell server

Shell is enabled from the configuration of the Neo4j kernel, see Section 21.2, “Server Configuration”. Here’s some sample configurations:

# Using default values
enable_remote_shell = true
# ...or specify custom port, use default values for the others
enable_remote_shell = port=1234

When using the Neo4j server, see Section 21.2, “Server Configuration” for how to add configuration settings in that case.

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.

31.1.2. 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)$

31.1.3. 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

31.1.4. 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

31.1.5. 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. So some examples of usage:

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