Day 7 - 90DaysofDevOps

Understanding package manager and systemctl

Package Manager

It is a tool in the operating system that allows the user to install, upgrade or remove software packages. These go by different names for different OS. In Linux it is Yum, in Ubuntu(Debian) it is apt-get, etc.

What is a Package?

It is an application that can be a command line tool, a GUI application or a software library that may be required by other applications. A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.

Let's dive into some examples of installing a package.

Installing Docker

In Ubuntu for installing Docker

Follow command:-

sudo apt-get update

sudo apt-get install docker.io -y

sudo usermod -aG docker $USER

sudo reboot

Installing Jenkins

For installing Jenkins we need to install Java first :

Steps to install Java

sudo apt update
sudo apt install openjdk-11-jre
java -version

After installing Java we can install Jenkins

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins

Systemctl

Systemctl is used to detect the state of an installed package whether it is in running, stopped, enabled or disabled state. It is used to change the state of any packages according to the user's needs.

systemctl start <package>

It is used to start the service of any application package.

systemctl stop <package>

It is used to stop the service of any installed package.

systemctl status <package>

It is used to check the current state of the application package.

systemctl enable <package>

It ensures the condition of application services remains the same even after the instance(VM) restarts.

Let's check the systemctl for the installed application i.e. Docker and Jenkins.