Work with the CLI on *nix

If you have administrator or root privileges, you can simplify CLI access by adding the top level directory of your Splunk Enterprise installation, $SPLUNK_HOME/bin, to your shell path. If you installed Splunk Enterprise in a different directory, specify that directory in the following commands.

This example works for Linux/BSD/Solaris users who installed Splunk Enterprise in the default location:

CODE
# export SPLUNK_HOME=/opt/splunk
# export PATH=$SPLUNK_HOME/bin:$PATH

This example works for Mac users who installed Splunk Enterprise in the default location:

CODE
# export SPLUNK_HOME=/Applications/Splunk
# export PATH=$SPLUNK_HOME/bin:$PATH

Now you can invoke CLI commands using:

CODE
splunk <command>

To set the $SPLUNK_HOME environment variable while working in a CLI session:

  • In *nix: source /opt/splunk/bin/setSplunkEnv
  • In Windows: splunk.exe envvars > setSplunkEnv.bat & setSplunkEnv.bat

Splunk CLI skips password prompting for *nix users with access to the /home directory

On a *nix machine, if a *nix user that runs the Splunk CLI has access to the /home directory on that machine, the CLI does not prompt for the Splunk user password.

Mac OS X requires elevated privileges to access system files or directories

Mac OS X requires superuser level access to run any command that accesses system files or directories. Run CLI commands using sudo or "su -" for a new shell as root. The recommended method is to use sudo. (By default the user "root" is not enabled but any administrator user can use sudo.)