Running elasticsearch (5.1.1) as root (kali linux)

So here is my problem, i installed elasticsearch and navigated to where it was installed and i tried to run it.
but when i type ./elasticsearch i get this message

Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
    at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
    at java.nio.file.Files.readAttributes(Files.java:1737)
    at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
    at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
    at java.nio.file.Files.walkFileTree(Files.java:2662)
    at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:100)
    at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:83)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272)
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121)
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112)
    at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
    at org.elasticsearch.cli.Command.main(Command.java:62)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82)
Refer to the log for complete error details.

Is there any solution to run it as root ? i tried creating a none-main user but it did not work

Your problem here is not that you're trying to run as root, but that you installed Elasticsearch from a package distribution but you're not running Elasticsearch from a service manager (Sys V init or systemd). When you install Elasticsearch from a distribution, it places the default configuration files in places that appropriate for running as a service (/etc/elasticsearch) and when you try to start Elasticsearch in standalone mode, Elasticsearch expects the configuration files to be in the config subdirectory off of the home of Elasticsearch (/usr/share/elasticsearch). That file does not exist, and therefore you get this message.

However, even if you get past this trouble, you still will not be able to run Elasticsearch as root. The ability to run Elasticsearch is disabled, to minimize the damage that can be done to your system if Elasticsearch is exploited.

So, take these two pieces of information into consideration when you try to get Elasticsearch working with a non-root user. Either run Elasticsearch as a service with your current installation, or remove the package installation and install using one of the archive distributions (zip or tar.gz).

First of all thank you for the reply.
now about your suggestion i already downloaded the .tar and executed elasticsearch from there here is what is shows:

[2016-12-26T22:37:54,758][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.1.jar:5.1.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.1.jar:5.1.1]
    ... 6 more

Could you give me any hint about this error ?

Also i can already run elasticsearch as a service and i can query it with a CURL and i also can visualize my logstash data in kibana after i send through elasticsearch output.

my second question is, What is the difference when i run it as a service and when i run it as a standalone

As I said in my previous reply: your problem was not due to you running as root but that even if you fixed that problem you would still not be able to run as root.

The main difference is ease of management.

1 Like

Thank You :grinning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.