How to install Jenkins on Linux


On this post we’re gonna go through the process on how to install Jenkins on Linux. We will cover the steps of installing Jenkins on Ubuntu/Debian distros and on Fedora/CentOS.

We tested this process on  AWS and it’s EC2 instance, but also on couple of virtual machines running from a local computer. So, this means that you can use these steps to install Jenkins on your AWS instance or any other Linux machine which is cloud hosted or on your local Linux machine.

Apart from this method, we also covered the process of installing and deploying Jenkins as a Docker container. To see the process how it’s done, you can check it out on this post.

Install Jenkins on Ubuntu/Debian

Before installing Jenkins on Debian or Debian based distros such as Ubuntu, make sure that you have Java installed first. Jenkins requires to have Java installed and it runs on Java version 8 minimum. To install Java, you can do this with these commands:

sudo apt update

sudo apt install openjdk-8-jdk

After Java is installed, then we can continue with the Jenkins installation. First we need to add Jenkins repository. After the repository is added, we can install Jenkins. Use the commands from bellow:

wget -q -O - | sudo apt-key add -

sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

sudo apt update

sudo apt install jenkins

When you run these commands, you should get output like on the images from bellow.

install jenkins on linux

Once the installation is finished, start the jenkins and check if it’s running and it’s status. We can do this with these commands:

sudo service jenkins start

sudo systemctl status jenkins

If Jenkins loads up correctly, you should see an output like on the image:

install jenkins on ubuntu

Install Jenkins on Fedora/CentOS

To install Jenkins on Fedora, procedure is similar. Add repository, install Jenkins, then start Jenkins. Java is also required but for Fedora install command will install Java as well alongside with Jenkins. You can use these commands:

For repositories:

sudo wget -O /etc/yum.repos.d/jenkins.repo

sudo rpm --import

To install Jenkins and Java:

sudo dnf upgrade && sudo dnf install jenkins java

To install Java on CentOS:

sudo yum install java-1.8.0-openjdk-devel

And to install Jenkins:

curl --silent --location | sudo tee /etc/yum.repos.d/jenkins.repo

sudo rpm --import

sudo yum install jenkins

Commands to start Jenkins and to check it’s status are same as for other distros:

sudo service jenkins start

sudo systemctl status jenkins

Accessing and configuring Jenkins

Once you installed Jenkins, you can access it via browser by typing in the address where the Jenkins is installed - http://youripaddress:8080. The setup wizard will start and the first will be a prompt to unlock Jenkins which asks from you to enter the Administrator password. The password is generated by the wizard and we need to find it in the Jenkins folder.

You can see on the prompt page where the administrator password is located and you can see the password with this command:

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

You’ll get an output like this:

install jenkins on debian

Paste that password and continue. Next screen is asking which plugins to install, the default ones or you’ll choose which one to install. You can go ahead and go with the default ones, but that is up to you.

Next is to create the admin user and after that will come the last step is to add the URL for Jenkins but that can be skipped or just leave it as is and you’re ready to go.

jenkins linux setup

jenkins linux setup


Let’s summarized what we have demonstrated in this article - we went through the steps on how to install Jenkins on Linux.

We successfully installed Jenkins on various Linux distros(Debian/Ubuntu/Fedora/CentOS) and ran the setup for it so it can start running right away. One note - if you have a firewall active and pre-configured, it can cause issues like Jenkins not to run at all. Solution for that is to add Jenkins in the firewall exceptions and to add inbound rule for the 8080 port. 

Also what is good to mention is, since Jenkins uses Java to run all it’s services, it can be resource heavy for one team to run pipelines, builds and tests. For Jenkins to run properly, it needs at least 1 GB of RAM. But for a small team build, it works at best having at least 4GB of RAM with 2 CPU cores or more.

Hope you found the post useful.

Thank you for your time.