How To Install SonarQube on Ubuntu 20.04 LTS

Install SonarQube on Ubuntu 20.04

In this tutorial, we will show you how to install SonarQube on Ubuntu 20.04 LTS. For those of you who didn’t know, SonarQube is an open-source web-based tool to manage code quality and code analysis. SonarQube includes features like bug and vulnerability detection and code tracking. SonarQube can integrate into GitHub, Azure DevOps, Bitbucket, GitLab, and Docker. If you happen to have an on-premise Linux server, or a cloud account with the likes of AWS, Google Cloud, or Azure, handy, you can deploy the community edition of SonarQube for free.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the SonarQube on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.


  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, and any other Debian-based distribution like Linux Mint or elementary OS.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install SonarQube on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Configure Kernel.

Now modify the kernel system limits. For this we must set the following:

  • vm.max_map_count must be greater than or equal to 524288
  • fs.file-max must be greater than or equal to 131072
  • The SonarQube user must be able to open at least 131072 file descriptors
  • The SonarQube user must be able to open at least 8192 threads
sudo nano /etc/sysctl.conf

Add the following lines to the bottom of that file:

ulimit -n 65536
ulimit -u 4096

Next, open the limits.conf file with the command:

sudo nano /etc/security/limits.conf

At the end of this file, add the following:

sonarqube   -   nofile   65536
sonarqube   -   nproc    4096

Then, reboot your system so the changes will take effect.:


Step 3. Installing Java.

Run the following command to install OpenJDK and JRE 11:

sudo apt install openjdk-11-jdk
sudo apt install openjdk-11-jre

Step 4. Installing PostgreSQL.

SonarQube only works with PostgreSQL. Now we running the command below to install it:

sudo apt install postgresql postgresql-contrib

Once done, start and enable the database service with the commands:

sudo systemctl enable postgresql
sudo systemctl start postgresql

Now we must set a password for the PostgreSQL user with the command:

sudo passwd postgres

Login as a PostgreSQL superuser and Create SonarQube PostgreSQL Database and Database user:

sudo -Hiu postgres
createuser sonaradmin
createdb -O sonaradmin sonarqubedb
ALTER USER sonaradmin WITH ENCRYPTED password 'changeme';

Step 5. Installing SonarQube on Ubuntu 20.04.

Now download the latest version of the SonarQube installer from the official website:

sudo unzip -d /opt

Move extracted setup to /opt/sonarqube directory:

sudo mv /opt/sonarqube- /opt/sonarqube

Step 5. Configure SonarQube.

Now we create a group as sonar:

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

Next, open the SonarQube configuration file using your favorite text editor:

nano /opt/sonarqube/conf/

Find the following lines:


Uncomment and Type the PostgreSQL Database username and password which we have created in the above steps and add the Postgres connection string:


Next, edit the sonar script file and set RUN_AS_USER:


Now to start SonarQube:

sudo su sonar
cd /opt/sonarqube/bin/linux-x86-64/

Next, run the script to start SonarQube:

./ start

To check if SonarQube is running enter the below command:

./ status

Step 6. Configure Systemd service.

Let’s now create a systemd file, so the SonarQube service can be controlled. Create the file with the command:

sudo nano /etc/systemd/system/sonar.service

Add the following line:

Description=SonarQube service


ExecStart=/opt/sonarqube/bin/linux-x86-64/ start
ExecStop=/opt/sonarqube/bin/linux-x86-64/ stop




Save and close the file, you can now start and enable the SonarQube service with the following two commands:

sudo systemctl start sonarqube
sudo systemctl enable sonarqube

Step 7. Accessing SonarQube Web Interface.

Once successfully installed, access the SonarQube using browser-type server IP followed by port 9000:


You should eventually see a login screen, where you’ll use the default credentials of admin/admin. Upon successful authentication, you’ll be required to change the default password. Once you’ve taken care of that, you’ll find yourself at the SonarQube main page:

Install SonarQube on Ubuntu 20.04

Congratulations! You have successfully installed SonarQube. Thanks for using this tutorial for installing the SonarQube on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official SonarQube website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button