Table of contents
Package Manager
A package manager is a software tool that allows users to install, remove, upgrade, configure, and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like apt-get, yum, and Pacman.
But what is Package?
Packages are used to distribute software applications, libraries, kernel modules, binary executables, and other types of software components. A package is usually referred to as an application but it could be a GUI application, command line tool, or a software library (required by other software programs).
Packages can be installed on a Linux system using a package manager, which automates the process of downloading, installing, and configuring packages.
Types of Package Managers
Package Managers differ based on the packaging system but the same packaging system may have more than one package manager. For example, RPM has Yum and DNF, package managers. For DEB, you have apt-get, aptitude command line-based package managers.
A few types of Packages Managers are:
Binary Package Managers: Yum, apt-get.
Language-specific Package Managers: pip (for Python), npm (for Node.js)
Application-specific Package Managers: brew (for macOS)
Container Package Managers: Docker, Podman.
Task 1: Install docker and Jenkins in your system from your terminal using package managers.
I am using Ubuntu, hence the package manager I am using is apt-get.
Docker Installation
sudo apt-get update
sudo apt-get install docker.io
The "sudo apt-get update" command downloads the latest package lists from the repositories and updates the local cache with information about new and updated packages that are available for installation.
To check if docker is installed, we can execute the following commands:
sudo docker info
If Docker is installed, it provides detailed information about the Docker installation, including the Docker version, operating system version, storage driver, number of containers and images, and other important details about the Docker environment.
Jenkins Installation
Jenkins has minimum prerequisites, make sure you meet the requirements which are mentioned on the official website of Jenkins: Jenkins prerequisites for installation on Linux.
One of the main prerequisites is Java. So let's install Java also.
sudo apt update
sudo apt install openjdk-11-jre
The above commands install Java. To verify if Java is installed, the command below helps:
java -version
The output comes as below stating the Java version.
Let us install Jenkins using the package manager now.
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
This command adds the Jenkins GPG key to the system's keyring, which is used to verify the authenticity of the Jenkins packages that are downloaded from the repository.
echo 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
This command adds the Jenkins repository to the system's list of package sources, making it possible to install and update Jenkins packages using the system's package manager (e.g. apt-get
).
sudo apt-get update
sudo apt-get install jenkins
There are multiple ways to verify the installation of Jenkins. One way is to check the status of Jenkins using systemctl or service commands. Another way is to check the Jenkins installation directory. By default, Jenkins is installed in the /var/lib/jenkins
directory.
If the above services are installed or not, running or not can be checked by the usage of commands like systemctl. Let's discuss the same in the coming sections.
Task 2: Brief on how to install these tools using package managers on Ubuntu and CentOS.
Package Manager on Ubuntu:
Ubuntu uses the APT (Advanced Package Tool) package manager. It comes pre-installed, but in case it's not installed, you can install it using the following command:
sudo apt-get update
sudo apt-get install apt
To install Docker on Ubuntu you can use the following command:
sudo apt-get update
sudo apt-get install docker.io
To install Jenkins on Ubuntu you can use the following command:
sudo apt-get update
sudo apt-get install jenkins
Package Manager on CentOS:
CentOS uses the YUM (Yellowdog Updater, Modified) package manager. You can install it using the following command:
sudo yum update
sudo yum install yum
CentOS 8 and later versions have switched to dnf as the default package manager.
sudo dnf install dnf
To install Docker on CentOS you can use the following command:
sudo yum install docker
To install Jenkins on CentOS you can use the following command:
Make sure that Java is installed on the CentOS. First, add the Jenkins repository to system and then install Jenkins using the below commands:
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install jenkins
systemctl and systemd
systemctl
is a command-line utility used to control the systemd system and service manager on Linux systems. It allows users to start, stop, enable, disable, and manage various system services, timers, targets, and sockets.
systemd
is a system and service manager that provides a range of features such as parallel startup of system services, on-demand starting of daemons, and tracking of processes using Linux control groups. systemd
is responsible for managing the system initialization process and starting system services at boot time. It also provides a unified API for managing system services across different Linux distributions (not all), making it easier to manage and troubleshoot services across different systems.
Task 3: Check the status of the docker service in your system
To check the status of Docker the below command is used:
sudo systemctl status docker
The output will be like below, which shows that the Docker service is active and running.
Task 4: Stop the service Jenkins and post before and after screenshots.
First, let us check the status of Jenkins after installation. The service is active and running.
sudo systemctl status jenkins
Now, let us stop the service using the below command. The output shows that the service is Inactive (dead).
sudo systemctl stop jenkins
sudo systemctl status jenkins
Let's start the service again. The service becomes Active (Running) again.
sudo systemctl start jenkins
sudo systemctl status jenkins
Task 5: systemctl vs service
Before explaining things, let us consider the below:
eg. systemctl status docker
vs service docker status
Both systemctl status docker
and service docker status
commands are used to check the status of the Docker service, but they use different command systems.
So let us understand how different are systemctl and service commands.
systemctl
and service
are both commands used to manage system services on Linux systems, but they use different service management systems.
service command
service
is an older command that was used to manage system services on older Linux distributions that used the SysVinit system.It provides a simple interface to start, stop, restart, and check the status of system services.
The
service
command reads service configuration files from the/etc/init.d/
directory and it is backward-compatible with older init scripts.
systemctl command
systemctl
is a newer command that is used to control and manage system services on modern Linux distributions that use systemd as the init system.It provides more advanced functionality than the
service
command, such as the ability to view the status of services in real-time, control the startup behavior of services, manage the service dependencies, and more.The
systemctl
command uses unit files located in/usr/lib/systemd/system/
and/etc/systemd/system/
to manage services.
Differences between systemctl and service commands for easy understanding
| systemctl | service |
Purpose | Manage and control system services | Start, stop, and check status of system services |
Service management system | Systemd | SysVinit |
Configuration files | /usr/lib/systemd/system/ and /etc/systemd/system/ | /etc/init.d/ |
To help me improve my blog and correct my mistakes, I am available on LinkedIn as Sneha K S. Do reach me and I am open to suggestions and corrections.
#Day7 #90DaysofDevops