How to Install SonarQube on Ubuntu 22.04 for Code Quality Checks
In modern software development, code quality is as important as functionality. Clean, maintainable, and secure code reduces technical debt and ensures long-term project success.

In modern software development, code quality is as important as functionality. Clean, maintainable, and secure code reduces technical debt and ensures long-term project success. One of the best tools available for monitoring and improving code quality is SonarQube. This open-source platform continuously inspects codebases, identifies vulnerabilities, and enforces coding standards. If you are a developer or DevOps engineer, learning how to install SonarQube on Ubuntu will give you a powerful way to automate code reviews and enhance security.

This guide explains how to install and configure SonarQube on Ubuntu 22.04 LTS, step by step.

 

Why Choose SonarQube?

SonarQube offers far more than static code analysis. Some of its major benefits include:

  1. Comprehensive Code Quality Checks – Detects bugs, security issues, and code smells.

  2. Supports Multiple Languages – Works with Java, Python, JavaScript, C/C++, PHP, and more.

  3. Integrates with CI/CD Tools – Fits seamlessly into Jenkins, GitHub Actions, and GitLab pipelines.

  4. User-Friendly Dashboard – Provides easy-to-read reports and visualizations.

  5. Enterprise-Grade Security – Identifies vulnerabilities and security hotspots.

With these features, SonarQube helps teams maintain high coding standards while automating routine reviews.

 

Prerequisites

Before you start the installation, ensure you have:

  • A server or system running Ubuntu 22.04 LTS.

  • At least 2 GB RAM and 2 CPUs (recommended).

  • A non-root user with sudo privileges.

  • Java 11 or higher installed.

For a cloud-based setup, you can follow this official reference guide: How to Use SonarQube on Ubuntu 22.04 LTS.

Step 1: Update Your System

First, update all packages to the latest versions:

sudo apt update && sudo apt upgrade -y

Step 2: Install Java

SonarQube requires Java to run. Install OpenJDK 17 with:

sudo apt install openjdk-17-jdk -y

 

Verify installation:

java -version

 

Step 3: Create a SonarQube User

It’s best practice to run SonarQube under a dedicated user account for security:

sudo adduser --system --no-create-home --group --disabled-login sonarqube

 

Step 4: Download and Install SonarQube

Navigate to the /opt directory and download SonarQube:

cd /opt

sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.1.69595.zip

sudo unzip sonarqube-9.9.1.69595.zip

sudo mv sonarqube-9.9.1.69595 sonarqube

 

Set permissions for the SonarQube user:

sudo chown -R sonarqube:sonarqube /opt/sonarqube

 

Step 5: Configure SonarQube as a Service

Create a systemd service file to manage SonarQube:

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

 

Add the following:

[Unit]

Description=SonarQube service

After=network.target

 

[Service]

Type=forking

ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start

ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

User=sonarqube

Group=sonarqube

Restart=always

LimitNOFILE=65536

LimitNPROC=4096

 

[Install]

WantedBy=multi-user.target

 

Save and exit. Then enable and start SonarQube:

sudo systemctl enable sonarqube

sudo systemctl start sonarqube

 

Step 6: Access the SonarQube Dashboard

Once running, SonarQube is accessible via your server’s IP address on port 9000. Open a browser and go to:

http://your_server_ip:9000

 

Log in with the default credentials:

  • Username: admin

  • Password: admin

You’ll be prompted to reset the password and can then start configuring your projects.

Conclusion

Learning how to install SonarQube on Ubuntu provides developers and teams with a reliable way to ensure code quality, detect vulnerabilities, and enforce coding standards. With its rich dashboard and CI/CD integration, SonarQube fits seamlessly into modern DevOps pipelines. By following the steps above, you can set up SonarQube on Ubuntu 22.04 quickly and start running detailed code quality checks.

 

For advanced configurations and additional resources, check the official guide here: Install SonarQube on Ubuntu 22.04 LTS. Take the first step toward cleaner, safer, and more maintainable code today!

 


disclaimer

Comments

https://nycityus.com/public/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!