Install Jenkins on Ubuntu and CentOS

Install Java
To run Jenkins your system need to have Java. So first we will install Java and then Jenkins.
Ubuntu:
Update the packages:
sudo apt updateInstall Java:
sudo apt install openjdk-11-jre -yCheck installation:
java -version
CentOS/Fedora:
- Install Java:
sudo dnf install java-11-openjdk
- Install Java:
Install Jenkins
Ubuntu:
Install keys and setup (run commands one by one):
You can also refer to this official website for updated packages:https://www.jenkins.io/doc/book/installing/linux/
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/nullecho deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
update packages:
sudo apt-get updateInstall Jenkins:
sudo apt-get install jenkins -y
CentOS/Fedora:
Install keys and setup (run commands one by one):
You can also refer to this official website for updated packages:https://www.jenkins.io/doc/book/installing/linux/
sudo wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.reposudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
Packages Update:
sudo dnf upgradeInstall Jenkins:
sudo dnf install jenkinsReload daemon:
sudo systemctl daemon-reload
Done. You have successfully installed Jenkins in your system.
Jenkins Status
Check the status of Jenkins with
systemctl:
Stop Jenkins
Use
systemctl stopto stop the Jenkins
Uninstall Jenkins
Stop Jenkins with
sudo systemctl stop jenkinsRemove the Jenkins packages
CentOS/Fedora machine:
sudo yum -y remove jenkinsUbuntu:
sudo apt-get remove --purge jenkins
Remove the Jenkins Working Directory:
rm -rf /var/lib/jenkinsRemove User and Group:
sudo userdel jenkinsReboot the system
sudo reboot nowAuto Remove Unwanted Packages(optional. Ubuntu):
sudo apt-get autoremove
Done. You have successfully removed Jenkins from your system.
To activate Jenkins and use it for automation, we will see it in another blog.
For further query do comment on this post.



