We cannot run SonarQube as a root user, if you run using root user it will stop automatically. The ideal approach will be to create a separate group and a user to run SonarQube

Create a group sonar

sudo groupadd sonar

Now add a user with control over the /opt/sonarqube directory

 sudo useradd -c "user to run SonarQube" -d /opt/sonarqube -g sonar sonar 
 sudo chown sonar:sonar /opt/sonarqube -R

Open SonarQube configuration file using your favourite text editor (e.g., nano or vim)

Learn More