Day 7: Understanding package management

Day 7: Understanding package management

ยท

3 min read

What is a package manager in Linux?

In simpler words, a package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on OS. The package manager can be a graphical application like a software centre or a command line tool like apt-get or Pacman.

What is a package?

A package is a compressed archive file that contains all the necessary files and information to install and manage a specific software program on a computer. These files typically include the program's executable files, libraries, documentation, and other essential resources.

Different kinds of package managers

There are various package managers used in different Linux distributions, and each has its own format for packages. Examples include:

  • For RPM packages: Yum and DNF

  • For DEB packages: apt-get and aptitude

Practical Example - Installing Docker and Jenkins on Ubuntu:

So now let's understand this with examples from Docker and Jenkins.

Pre-requisites: You must have sudo privileges and Java preinstalled for Jenkins.

  1. Installation of Docker on ubuntu:

sudo apt-get update
sudo apt-get install docker.io -y

After a successful installation, validate it with the below command.

docker --version

  1. Installation of Jenkins:

First, we have to add the Jenkins repo to our system.

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian/jenkins.io-2023.key
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

In the above command, we downloaded the gpg key with wget and saved it to our system, and after that, we added Jenkins repository information to the /etc/apt/sources.list.d/jenkins.list file. The echo command outputs the repository information, and tee writes it to the specified file.

Again, we need to update the package manager with sudo apt-get update.

Now we can install it using sudo apt-get install jenkins.

Validate the installation of Jenkins by checking version.

jenkins --version

We can also check the Jenkins installation by checking it on the browser with public-ip:8080 but we need to enable the 8080 port as we are using an AWS EC-2 instance. We can do that by editing the security groups inbound rule.

  1. Managing services:

Check the status of the docker service in your system

systemctl status docker

Stop the Jenkins Service

$ sudo systemctl stop jenkins

Enable Jenkins service to start automatically:

We can enable the service so that it will start automatically even after reboot.

$ sudo systemctl enable jenkins

Conclusion:

In conclusion, package managers play a crucial role in simplifying the management of software installations on Linux systems. The examples provided for installing Docker and Jenkins on Ubuntu illustrate the practical application of package managers, including updating, installing, and managing services. Understanding package management is fundamental for efficient software deployment and system administration in the Linux ecosystem.

ย