What is a package manager in Linux?
A package manager in Linux is a tool that automates the process of installing, updating, configuring, and removing software packages on a Linux system. It keeps track of what software is installed on your computer, and allows you to easily install new software, upgrade software to newer versions, or remove software that you previously installed
What is a package?
A package is a compressed file archive that contains all the files needed to install and run a specific piece of software. This includes the actual program files, configuration files, scripts, and metadata, which describes the package and its dependencies.
Types of Packages:
Binary Packages: These contain precompiled executables and libraries, ready to be installed on a system without needing to be compiled from source. Example formats include
.deb
(Debian-based systems) and.rpm
(Red Hat-based systems).Source Packages: These include the source code of the software, which needs to be compiled before installation. This allows customization during the build process.
Example Package Formats:
DEB: Used in Debian-based distributions like Ubuntu. Managed with tools like
dpkg
andapt
.RPM: Used in Red Hat-based distributions like Fedora and CentOS. Managed with tools like
rpm
,yum
, anddnf
.TAR.GZ/TAR.XZ: These are generic compressed archive formats often used for distributing source code.
Different kinds of package managers:
APT (Advanced Package Tool): Used in Debian-based distributions like Ubuntu. Command-line utility:
apt-get
orapt
.YUM (Yellowdog Updater, Modified): Used in Red Hat-based distributions like CentOS and Fedora. Replaced by
dnf
in newer versions.DNF (Dandified YUM): An improved version of YUM, used in Fedora, Red Hat, and CentOS.
Zypper: Used in SUSE and openSUSE.
Pacman: Used in Arch Linux and its derivatives.
Example Commands:
APT:
sudo apt update
- Updates the package list.sudo apt install package_name
- Installs a package.sudo apt remove package_name
- Removes a package.
YUM/DNF:
sudo yum install package_name
- Installs a package using YUM.sudo dnf install package_name
- Installs a package using DNF.
Pacman:
sudo pacman -S package_name
- Installs a package.sudo pacman -R package_name
- Removes a package.
Steps to Install Docker
Ensure your system is up to date
sudo yum update -y
Install necessary packages for managing repositories
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Add Docker's official repository to your system
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install the latest version of Docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
Start the Docker service and enable it to start on boot
sudo systemctl start docker
sudo systemctl enable docker
Check if Docker is installed correctly
docker --version
Steps to Install Jenkins
Ensure your system is up to date
sudo yum update -y
Install Java
sudo yum install -y java-17-openjdk
Note : Jenkins requires Java17 or Java21 to work
Add the official Jenkins repository to your system
sudo yum install -y wget
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
Install Jenkins
sudo yum install -y jenkins
Start the Jenkins service and enable it to start on boot
sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins
Checking the status of docker installed in system
- stop the service jenkins and post before and after screenshots
systemctl vs service
systemctl
is the modern, recommended tool for managing services on most current Linux distributions (especially those using systemd)
Common Use : Modern systems, RHEL 7+, CentOS 7+, Ubuntu 15.04+
service
is an older tool used by systems with SysVinit or Upstart. While it still works on some systems, it’s being replaced by systemctl
in newer systems
Common Use : Older systems (RHEL 6, Ubuntu 14.04)