Link Search Menu Expand Document
Start for Free

Command Line Interface

This page describes the command line interace (CLI) to interact with Stardog. Please view Stardog and Stardog Admin CLI Reference Manuals for a full description of all CLI commands.

Page Contents
  1. Overview
  2. Security Considerations
  3. Command Groups
  4. Connection Strings
    1. Example Connection Strings
  5. Autocomplete
  6. Installing Man Pages Locally

Overview

Stardog’s command-line interface (CLI) comes in two parts:

  1. stardog-admin: administrative client
  2. stardog: a user’s client

The admin and user’s tools operate on local or remote databases using HTTP protocol. These CLI tools are self-documenting, and their help output is their canonical documentation. In other words, if there is a conflict between this documentation and the output of the CLI tools’ help command, the CLI output is correct.

Security Considerations

We divide administrative functionality into two CLI programs for reasons of security: stardog-admin will need, in production environments, to have considerably tighter access restrictions than stardog.

For usability, Stardog provides a default user admin and password admin in stardog-admin commands if no user or password are given. This is insecure; before any serious use of Stardog is contemplated, read the Security section at least twice, and then–minimally–change the administrative password to something we haven’t published online!

Command Groups

The CLI tools use “command groups” to make CLI subcommands easier to find. To print help for a particular command group, just ask for help:

stardog help [command_group_name]

See the Stardog CLI Reference and Stardog Admin CLI Reference for the canonical list of commands

The main help command for either CLI tool will print a listing of the command groups:

$ stardog help                                                                               
usage: stardog [ --krb5 ] [ --krb5-disable-rdns ] <command> [ <args> ]

Commands are:
    data        Commands which can modify or dump the contents of a database
    doc         Unstructured document processing
    file        Commands for manipulating rdf files
    graphql     Commands for working with GraphQL
    help        Display help information
    icv         Commands for working with Stardog Integrity Constraint support
    namespace   Commands which work with the namespaces defined for a database
    query       Commands which query a Stardog database
    reasoning   Commands which use the reasoning capabilities of a Stardog database
    tx          Commands for managing transactions
    version     Prints information about this version of Stardog.

See 'stardog help <command>' for more information on a specific command.

To get more information about a particular command, simply issue the help command for it including its command group:

stardog help query execute

Finally, everything here about command groups, commands, and online help works for stardog-admin

Connection Strings

You need to know how to make a connection string to talk to a Stardog database. A connection string may consist solely of the database name in cases where

  1. Stardog is listening on the standard port 5820; and
  2. the command is invoked on the same machine where the server is running.

In other cases, a “fully qualified” connection string, as described below, is required.

Further, the connection string is assumed to be the first argument of any command that requires a connection string. Some CLI subcommands require a Stardog connection string as an argument to identify the server and database upon which operations are to be performed.

Connection strings are URLs and may either be local to the machine where the CLI is run or they may be on some other remote machine.

Stardog connection strings use the http:// protocol scheme.

Example Connection Strings

To make a connection string, you need to know the machine name, the port Stardog Server is running on and the name of the database:

{scheme}{machineName}:{port}/{databaseName};{connectionOptions}

Here are some example connection strings

  1. http://myserver/myStardog/myDb
  2. http://localhost:12345/myOtherDb
  3. http://169.175.100.5:1111/oneLastDb;reasoning=true

Using the default port for Stardog’s use of HTTP protocol simplifies connection strings. connectionOptions are a series of ; delimited key-value pairs which themselves are = delimited. Key names must be lowercase and their values are case-sensitive.

Autocomplete

Stardog also supports CLI autocomplete via bash autocompletion. To install autocomplete for bash shell, you’ll first want to make sure bash completion is installed.

  • brew install bash-completion
    

    To enable, edit .bash_profile:

    if [ -f `brew --prefix`/etc/bash_completion ]; then
      . `brew --prefix`/etc/bash_completion
    fi
    
  • sudo port install bash-completion
    

    Then, edit .bash_profile

    if [ -f /opt/local/etc/bash_completion ]; then
       . /opt/local/etc/bash_completion
    fi
    
  • sudo apt-get install bash-completion
    

    Now put the Stardog autocomplete script—stardog-completion.sh which is found in your distribution—into your bash_completion.d directory, typically one of /etc/bash_completion.d, /usr/local/etc/bash_completion.d or ~/bash_completion.d.

    Alternately you can put it anywhere you want, but tell .bash_profile about it:

    source ~/.stardog-completion.sh
    
  • sudo yum install bash-completion
    

    Now put the Stardog autocomplete script—stardog-completion.sh which is found in your distribution—into your bash_completion.d directory, typically one of /etc/bash_completion.d, /usr/local/etc/bash_completion.d or ~/bash_completion.d.

    Alternately you can put it anywhere you want, but tell .bash_profile about it:

    source ~/.stardog-completion.sh
    

Installing Man Pages Locally

To install the man pages locally in your Unix-like environment:

$ cp <stardog-installation-directory>/docs/man1/* /usr/local/share/man1
$ cp <stardog-installation-directory>/docs/man8/* /usr/local/share/man8
$ mandb
$ man stardog-admin-server-start