📖 Scenario: You are setting up a Jenkins server on a Linux machine to automate software builds and deployments. Jenkins requires installation and configuration before use.
🎯 Goal: Learn how to install Jenkins on a Linux system step-by-step using command line instructions.
📋 What You'll Learn
Use the official Jenkins repository to install Jenkins
Install Java OpenJDK 11 as a prerequisite
Start and enable the Jenkins service
Check the Jenkins service status
💡 Why This Matters
🌍 Real World
Installing Jenkins on Linux is a common task for setting up continuous integration servers in software development environments.
💼 Career
Knowing how to install and configure Jenkins is essential for DevOps engineers and system administrators to automate build and deployment pipelines.
Progress0 / 4 steps
1
Install Java OpenJDK 11
Run the command sudo apt-get update to update package lists, then install Java OpenJDK 11 using sudo apt-get install -y openjdk-11-jdk.
Jenkins
Hint
Jenkins requires Java. Use apt-get commands to update and install Java OpenJDK 11.
2
Add Jenkins Repository and Key
Add the Jenkins repository key using wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - and add the Jenkins repository with sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'.
Jenkins
Hint
Use wget to download the Jenkins key and add the Jenkins repository to your system.
3
Install Jenkins Package
Update package lists again with sudo apt-get update and install Jenkins using sudo apt-get install -y jenkins.
Jenkins
Hint
After adding the Jenkins repository, update package lists again and install Jenkins.
4
Start and Check Jenkins Service
Start Jenkins service with sudo systemctl start jenkins, enable it to start on boot with sudo systemctl enable jenkins, and check its status using sudo systemctl status jenkins.
Jenkins
Hint
Use systemctl commands to start, enable, and check Jenkins service status.
Practice
(1/5)
1. What is the first step before installing Jenkins on a Linux system?
easy
A. Create a Jenkins user account manually
B. Start the Jenkins service immediately
C. Add Jenkins repository key without installing Java
D. Install Java (OpenJDK) because Jenkins requires it to run
Solution
Step 1: Understand Jenkins prerequisites
Jenkins requires Java to run, so Java must be installed first.
Step 2: Confirm prerequisite installation order
Installing Java first ensures Jenkins can run properly after installation.
Final Answer:
Install Java (OpenJDK) because Jenkins requires it to run -> Option D
Quick Check:
Java installation is the first step [OK]
Hint: Always install Java before Jenkins on Linux [OK]
Common Mistakes:
Trying to start Jenkins before Java is installed
Skipping Java installation
Adding repository key before Java
2. Which command correctly adds the Jenkins repository key on a Debian-based Linux system?
easy
A. curl https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-get update
B. sudo rpm --import https://pkg.jenkins.io/debian-stable/jenkins.io.key
Hint: Use wget and apt-key to add Jenkins key on Debian [OK]
Common Mistakes:
Using rpm commands on Debian
Trying to install a non-existent package 'jenkins-key'
Using curl without proper piping
3. After adding the Jenkins repository and updating package lists, what is the output of the command sudo systemctl status jenkins immediately after installation but before starting Jenkins?
medium
A. Active: active (running)
B. Active: inactive (dead)
C. Active: failed
D. Unit jenkins.service could not be found
Solution
Step 1: Understand Jenkins service state after installation
Installing Jenkins does not start the service automatically; it remains inactive.
Step 2: Interpret systemctl status output
Since Jenkins is not started yet, status shows inactive (dead), not running or failed.
Final Answer:
Active: inactive (dead) -> Option B
Quick Check:
Service inactive before start command [OK]
Hint: Service is inactive until explicitly started [OK]
Common Mistakes:
Assuming service auto-starts after install
Confusing 'failed' with 'inactive'
Expecting 'unit not found' after install
4. You installed Jenkins on Linux but the command sudo systemctl start jenkins fails with 'Failed to start jenkins.service: Unit not found.' What is the most likely cause?
medium
A. Jenkins package was not installed properly or repository not added
B. Java is not installed on the system
C. Firewall is blocking Jenkins port 8080
D. You need to reboot the system before starting Jenkins
Solution
Step 1: Analyze the error message
'Unit not found' means systemd cannot find the Jenkins service file, likely missing installation.
Step 2: Identify common causes
Missing or incorrect repository setup or failed package install causes service file absence.
Final Answer:
Jenkins package was not installed properly or repository not added -> Option A
Quick Check:
Missing service file means Jenkins not installed correctly [OK]
Hint: Check Jenkins package and repo if service unit missing [OK]
Common Mistakes:
Blaming firewall for service start failure
Assuming Java missing causes 'unit not found'
Thinking reboot fixes missing service unit
5. You want to install Jenkins on a Linux server and ensure it starts automatically on boot. Which sequence of commands correctly achieves this?