Run Splunk Enterprise as a different or non-root user
On *nix based systems, you can run Splunk Enterprise as a user other than root. This is a Splunk best practice and you should configure your systems to run the software as a non-root user where possible.
If you run Splunk software as a non-root user, confirm that the software can perform the following:
- Read the files and directories that you configure it to monitor. Some log files and directories might require root or superuser access to be indexed.
- Write to the Splunk Enterprise directory and execute any scripts configured to work with your alerts or scripted input. See Configure a script for an alert action in the Alerting Manual or Get data from APIs and other remote data interfaces through scripted inputs in Getting data in.
- Bind to the network ports it is listening on. Network ports below 1024 are reserved ports that only the root user can bind to.
If you run Splunk Enterprise as a root user, see Running Splunk Enterprise as a root user.
Set up Splunk software to run as a non-root user
- Install Splunk software as the root user, if you have root access. Otherwise, install the software into a directory that has write access for the user that you want Splunk software to run as.
- Change the ownership of the
$SPLUNK_HOMEdirectory to the user that you want Splunk software to run as. - Start the Splunk software.
Example instructions on how to install Splunk software as a non-root user
In this example, $SPLUNK_HOME represents the path to the Splunk Enterprise installation directory.
- Log into the machine that you want to install Splunk software as root.
- Create the
splunkuser and group.On Linux:
useradd splunk groupadd splunkOn Mac OS: You can use the System Preferences > Accounts System Preferences panel to add users and groups.
- Install the Splunk software, as described in the installation instructions for your platform. See Installation instructions. Note: Do not start Splunk Enterprise yet.
- Run the
chowncommand to change the ownership of thesplunkdirectory and everything under it to the user that you want to run the software.chown -R splunk:splunk $SPLUNK_HOMENote: If thechownbinary on your system does not support changing group ownership of files, you can use thechgrpcommand instead. See themanpages on your system for additional information on changing group ownership. - Become the non-root user.
su - <user>Note: You can also log out of the root account and log in as that user. - Start the Splunk software.
$SPLUNK_HOME/bin/splunk start
Use sudo to start or stop Splunk software as a different user
If you want to start Splunk Enterprise as the splunk user while you are logged in as a different user, you can use the sudo command.
sudo -H -u splunk $SPLUNK_HOME/bin/splunk start
sudo -H -u splunk $SPLUNK_HOME/bin/splunk stop
This example command assumes the following:
- That Splunk Enterprise has been installed in the default installation directory. If Splunk Enterprise is in an alternate location, update the path in the command accordingly.
- That your system has the
sudocommand available. If this is not the case, usesuor get and installsudo. - That you have already created the user that you want Splunk software to run as.
- That the
splunkuser has access to the/dev/urandomdevice to generate the certificates for the product.
Further reading
- To configure Splunk software to run at boot time as a non-root user, see Enable boot-start as a non-root user in the Admin Manual.
- To learn how to install Splunk Enterprise on Windows using a user that is not an administrator, see Choose the user Splunk Enterprise should run as.
- To learn how to change the Windows user that Splunk Enterprise services use, see Change the user selected during Windows installation.
Running Splunk Enterprise as a root user
| This feature is deprecated. |
|---|
| Running Splunk Enterprise as a root user on MacOS and Linux is deprecated. Although this configuration choice continues to be available, it will be removed in a future release. In the version 10.0 Release Notes, see the topic Deprecated features. |