HomeBlogDevOpsHow to Install Jenkins on Ubuntu 22.04? [Step-by-Step Guide]

How to Install Jenkins on Ubuntu 22.04? [Step-by-Step Guide]

01st Jul, 2024
view count loader
Read it in
11 Mins
In this article
    How to Install Jenkins on Ubuntu 22.04? [Step-by-Step Guide]

    Automation is the key to the quick delivery of software versions that are not only speedier but also flawless and bug free in the dynamic world of software development. The foundation of this automation is made up of technologies that facilitate the creation, testing, and implementation of code changes. Jenkins is the ideal technology to help you expedite your efforts if you're trying to streamline your software development cycle through continuous integration and delivery.  

    With the help of this post, I will provide a thorough walkthrough of how to install Jenkins on Ubuntu 22.04, covering everything from configuration to the necessary prerequisites for a smooth Jenkins setup on Ubuntu. Explore Jenkins' features and see how they can improve your development process. 

    Step to Install Jenkins on UbuntuDescription
    1. Update & Upgrade:Ensure your system is up-to-date: sudo apt update && sudo apt upgrade -y
    2. Install Java:Install OpenJDK 11: sudo apt install openjdk-11-jdk -y
    3. Update Package Lists:Update package lists to include the new repository: sudo apt update
    4. Install Jenkins:Install Jenkins: sudo apt install jenkins -y
    5. Start Jenkins:Start the Jenkins service: sudo systemctl start jenkins
    6. (Optional) Configure Firewall:If needed, configure your firewall to allow access to the Jenkins port (default: 8080).
    7. Access Jenkins:Open a web browser and navigate to http://localhost:8080 to complete the initial setup.

    Prerequisites to Install Jenkins on Ubuntu 22.04

    The following are required to installing Jenkins on Ubuntu 22.04, 

    • Make sure your Ubuntu 22.04 machine is up and running, to verify that you are running Ubuntu 22.04, type the command cat /etc/os-release 
    • Jenkins runs on Java, so make sure you have JDK 11 installed. 
    • Make sure your machine has package managed installed such as apt to easily manage software packages. 

    A. Hardware Requirements: 

    • RAM- 4 GB (Recommended) 
    • Storage- more than 50 GB of Hard Disk Space (Recommended)        

    B. Software Requirements: 

    • Java: Jenkins runs on Java, so make sure you have JDK 11 installed. 
    • Web Browser: Any browser such as Google Chrome, Mozilla Firefox, Microsoft Edge. 
    • Make sure your machine has package managed installed such as apt to easily manage software packages.  
    • Make sure your Ubuntu 22.04 machine is up and running, to verify that you are running Ubuntu 22.04, type the command cat /etc/os-release. For help in the planning of production capability of a Jenkins installation on Ubuntu seChoosing the right hardware for Masters. 

    With these prerequisites in place, you will be ready to install Jenkins on your Ubuntu 22.04 machine. Elevate your skills with the KnowledgeHut DevOps Foundation Certification . 

    How to Install Jenkins on Ubuntu?

    Here is a step by step procedure on how to install Jenkins in Ubuntu 22.04:

    Step 1: Update the System 

    First, ensure that your package lists are up-to-date by running the following commands: 

    sudo apt update 
    sudo apt upgrade 

    Step 2: Install Java 

    For Java installation, we will use the version packaged with Ubuntu. To install the OpenJDK version of Java, begin by updating the apt package index:

    Begin by updating the apt package index to ensure you fetch the latest information:

    To check, please run the following command in the terminal: 

    java --version 
    • Jenkins needs Java for running, but it doesn't include certain distributions by default, and Java versions of Jenkins are incompatible. 
    • Multiple Java implementations are available to you. OpenJDK is currently the most popular one, which we will use in this guide. 
    • Being an open-source Java application, Jenkins requires the installation of OpenJDK 8 on your system. The apt repositories can directly access OpenJDK 8. 
    • The installation of OpenJDK from standard repositories is recommended. Open and enter the following in the terminal window: 
    sudo apt update 
    sudo apt install openjdk-8-jdk 
    • The download and installation will be requested. Press the "Y" button and press the Enter button to finish the process. 
    • Java 8 will be installed on your system. We are ready to download Jenkins package now as we have our requirements ready! 

    Step 3: Install Jenkins on Ubuntu

    The default Ubuntu packages for Jenkins are always behind the current version of the project itself. You may use the project-maintained packages to install Jenkins to take advantage of the newest patches and features. 

    1. Add the framework repository key: 

    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add  

    The device returns OK when the key is inserted. 

    Install Jenkins

    2. Next, link the repository of Debian packages to the sources.list of the server: 

    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' 

    3. When both are in place, upgrade to apt to use the new repository: 

    sudo apt update 

    4. Install Jenkins: 

    sudo apt install jenkins 

    Now we're going to start the Jenkins server, as Jenkins and its dependencies are in place. 

    Step 4: Start Jenkins 

    1. You can start Jenkins using systemctl: 

    sudo systemctl start jenkins 

    2. As systemctl does not display performance, you can use the status command to check that Jenkins has successfully launched: 

    sudo systemctl status jenkins

    If all went well, the start of the performance should demonstrate that the service is active and ready to boot: 


    jenkins.service - LSB: Start Jenkins at boot time 
       Loaded: loaded (/etc/init.d/jenkins; generated) 
       Active: active (exited) since Sat 2021-04-17 00:34:17 IST; 26s ago 
         Docs: man:systemd-sysv-generator(8) 
      Process: 17609 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCC 

    As Jenkins is running, so adjust the firewall rules to complete our further setup of Jenkins from the web browser. 

    Step 5: Opening the Firewall 

    1. Jenkins works by default on port 8080, so let's open the port with ufw: 

    sudo ufw allow 8080  

    2. Check ufw’s status: 

    sudo ufw status 

    You will see that traffic from anywhere is permitted to port 8080. 


    Status: active 
    To                         Action      From 
    --                         ------      ---- 
    8000                       ALLOW       Anywhere                   
    CUPS                       ALLOW       Anywhere                   
    27017                      ALLOW       Anywhere                   
    27017                      ALLOW               
    8080                       ALLOW       Anywhere                   
    8000 (v6)                  ALLOW       Anywhere (v6)              
    CUPS (v6)                  ALLOW       Anywhere (v6)              
    27017 (v6)                 ALLOW       Anywhere (v6)              
    8080 (v6)                  ALLOW       Anywhere (v6) 

    3. If the firewall is inactive, the following commands will allow OpenSSH and turn it back on: 

    sudo ufw allow OpenSSH 
    sudo ufw enable 

    We can finish the initial configuration with Jenkins install in Ubuntu and our firewall configured. 

    Note: If you decide to continue to use Jenkins, use a Nginx Reverse Proxy at Ubuntu 18.04 to configure Jenkins with SSL when your exploration has been completed to protect your passwords and any sensitive system or product information sent between the machine and the server in plain text. 

    Step 6: Setting Up Jenkins 

    1. To set up installation, visit Jenkins on its default 8080 port with your server domain name or IP address: http://your_server_ip_or_domain:8080 

    You should see the Unlock Jenkins screen, which displays the initial password's location:

    Unlock Jenkin

    2. You can use the cat command to display the password: 

    sudo cat /var/lib/jenkins/secrets/initialAdminPassword 

    3. Copy the alphanumeric terminal 32-character password and paste into the Administrator Password field, then click Continue. 



    The following screen shows the ability to install or select certain plugins: 

    Customize jenkins

    4. We will click on the option to install proposed plugins to start the installation process immediately. 

    5. When the installation is done, the first administrative user will be prompted. You can save this step and use your initial password to continue as an Admin. However, we will take some time to create the user. 

    The Jenkins default server is NOT encrypted to prevent data from being protected. Use the Nginx Reverse Proxy on Ubuntu 18.04 to configure Jenkins with SSL. This protects the information of users and builds transmitted through the web interface. 

    Create First Admin User

    6. You will see a configuration instance page, which asks you to confirm your Jenkins instance's URL of choice. Confirm either your server's domain name or the IP address of your server.  

    Instance Configuration

    7. Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"  

    Jenkins is ready

    Hit Start using Jenkins button and it will take you to the Jenkins dashboard.  

    Welcome to Jenkin

    Congratulations! You have completed the installation of Jenkins. 

    Step 7: Creation of New Build Jobs in Jenkins: 

    The freestyle job is a highly versatile and user-friendly choice. It's easy to set up and many of its options appear in many other build jobs. For all projects, you can use it. 

    Follow the following steps: 

    1. You have to login to your Jenkins Dashboard by visiting

    Welcome to jenkin

    2. Create New item: 

    Click on the New Item on the left-hand side of the dashboard.

     Create New item

    3. Fill the project description: 

    You can enter the job details as per your need.

     Fill the project description

    4. Source Code Management: 

    • Under source code management, enter the repository URL.
    • You can also use a Local repository. 

    5. Build Environment: 

    Now in the Build section, 

    • Click on the “Add build Setup” 
    • Select "Execute Windows batch command".

     Build Environment

    Now, add the java commands. In this article, we have used javac HelloWorld.java and java HelloWorld.   

     Build Environment

    6. Save the project: 

    Click Apply and save the project. 

    7. Build Source Code and check its status: 

    Click on “Build Now” on the left-hand side of the screen to create the source code. 

    8. Console Output: 

    Select the build number and click on “Console Output” to check the status of the build run. 

    Console Output

    When it shows success, it means that we have successfully run the HelloWorld program from the cGitHub Repository. 

    In case of failure, you can check the job logs by clicking on failure icon and debug the root cause.

    How to Uninstall Jenkins? 

    1 Initially, you need to stop the Jenkins service by executing the following command: 

    ```sudo service jenkins stop``` 

    2 Remove Jenkins using the following command: 

    ```sudo apt-get remove --purge jenkins  -y ``` 

    The -y flag automatically confirms the removal By following these two steps, you can uninstall Jenkins from your Ubuntu machine, ensuring a clean removal of the software. 

     Additionally, you can remove the Jenkins packages using the following command: 

    ```sudo apt-get remove --auto-remove jenkins``` 

    3. Now, verify the status of the Jenkins service with the following command: 

    ``` service jenkins status``` 

    For detailed guides on installing Jenkins on various platforms such as Windows, Linux, Mac, and more, explore our comprehensive article covering step-by-step instructions and prerequisites.

    Why Use Jenkins? 

    You need to consider continuous integration (CI) and continuous delivery (CD) to understand Jenkins: 

    • Continuous integration: the practice of continuous production combined with the main industry. 
    • Continuous delivery: the code is constantly delivered to an area after the code is ready for delivery. It could be for production or staging. The commodity is supplied to a consumer base that can provide QA or inspection by customers. 

    Developers update the code regularly in the shared repository (such as GitHub or TFS). Improvements made in the source code are made at the end of the day, making it difficult to identify the errors. So, Jenkins is used here. 

    Once a developer changes the repository, Jenkins will automatically enable the build and immediately warn you in the event of an error (Continuous Integration CI). 


    In this article, I walked through the step-by-step process of how to install Jenkins on Ubuntu 22.04, providing you with a thorough understanding. Additionally, we explored the uninstallation procedure, ensuring a complete coverage of managing Jenkins on your Ubuntu machine. By following this installation of Jenkins in Ubuntu - detailed step, you are well equipped with the knowledge to effortlessly set up and customize Jenkins according to your requirements. 

    Whether you are a new or an experienced user, this article serves as a valuable resource to streamline the installation and removal processes, allowing you to tailor it to your needs on Ubuntu. If you're looking to deepen your DevOps knowledge, consider exploring the DevOps Foundation Certification offered by KnowledgeHut.   

    Frequently Asked Questions (FAQs)

    1Where does Jenkins install on Ubuntu?

    Jenkins is commonly installed in the /var/lib/jenkins directory on Ubuntu, although alternative installation locations include /etc/jenkins and /usr/share/jenkins.

    2Are there any security considerations during Jenkins installation?

    Yes, please make sure the following considerations are addressed when setting up Jenkins:

    • Make sure you set up strong passwords for Jenkins when setting it up.
    • Make sure you have firewall enabled and have only allowed access to port where Jenkins is listening.
    • Regularly update plugins to take advantage of available security patches. 
    3How do I access the Jenkins web interface after installation?

    Once installation is complete, you can access the Jenkins UI by opening a web browser and navigating to http://<your-server-ip>:8080. Make sure you replace your server ip with your server IP. 

    4Can I install Jenkins on Ubuntu without root access?

    Generally, installation with the package managed requires root access, but if you don't have root access, you might need to work with your admin to install Jenkins and request for necessary permissions. Some limited installations or configurations might be possible without root access, but it depends on the specific requirements and restrictions of your system. 


    Abhresh Sugandhi


    Abhresh is specialized as a corporate trainer, He has a decade of experience in technical training blended with virtual webinars and instructor-led session created courses, tutorials, and articles for organizations. He is also the founder of Nikasio.com, which offers multiple services in technical training, project consulting, content development, etc.

    Share This Article
    Ready to Master the Skills that Drive Your Career?

    Avail your free 1:1 mentorship session.

    Your Message (Optional)

    Upcoming DevOps Batches & Dates

    NameDateFeeKnow more
    Course advisor icon
    Course Advisor
    Whatsapp/Chat icon