Table of contents
What is a package manager in Linux?
A package manager in Linux is a software tool that automates the process of installing, updating, configuring, and removing software packages on a Linux-based operating system. It simplifies software management by providing a centralized and organized way to handle software installation and maintenance.
What is a package?
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). A package is essentially an archive file containing the binary executable, configuration file, and sometimes information about the dependencies.
Different kinds 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.
You have to install docker and Jenkins in your system from your terminal using package managers
Docker Installation
Docker is a platform that lets you package, distribute, and run applications and their dependencies in isolated, consistent environments called containers, making it easier to develop, deploy, and manage software across different systems.
Open your terminal and run the following commands to install Docker:
sudo apt update
sudo apt install docker.io
After the installation is complete, you can start and enable the Docker service:
sudo systemctl start docker
sudo systemctl enable docker
To verify that Docker is installed and running, you can run:
docker --version
Congratulations! Docker is now installed on your system.
Jenkins Installation
Jenkins is a tool that automates repetitive tasks in software development, like building and testing code, making development and delivery faster and more efficient. It provides a platform for continuous integration and continuous delivery (CI/CD)
Add Jenkins Repository and Install:
sudo apt update
sudo apt install openjdk-11-jdk # Install Java 11 (required for Jenkins)
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
Start and Enable Jenkins:
sudo systemctl start jenkins
sudo systemctl enable jenkins
Unlock Jenkins:
Open a web browser and access http://localhost:8080
. You'll be prompted to enter an initial admin password. Retrieve the password using:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Installing Docker and Jenkins Using Package Managers on Ubuntu and CentOS
Installing Docker on Ubuntu:
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
Installing Jenkins on Ubuntu:
sudo apt update
sudo apt install openjdk-11-jdk
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
Installing Docker on CentOS:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce
sudo systemctl start docker
sudo systemctl enable docker
Installing Jenkins on CentOS:
Install Jenkins:
sudo yum install -y java-11-openjdk-devel
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
sudo yum install -y jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
What is systemctl and systemd?
systemctl
is the primary command-line tool for interacting with the systemd
init system. It allows you to control and manage system services, view their status, start or stop them, enable or disable them to run at boot
Common systemctl
commands include:
systemctl start <service>
: Start a specific service.
systemctl stop <service>
: Stop a specific service.
systemctl restart <service>
: Restart a specific service.
systemctl enable <service>
: Enable a service to start at boot.
systemctl disable <service>
: Disable a service from starting at boot.
systemctl status <service>
: View the status of a service.
systemctl
is the interface through which users and administrators interact with the systemd
init system to manage services and perform various system-related tasks. It provides a user-friendly and standardized way to control and monitor services and the system's behavior.
Check the status of docker service in your system (make sure you completed above tasks, else docker won’t be installed)
Read about the commands systemctl vs service
systemctl
is associated with the systemd
init system, which is the modern init system used by many Linux distributions.
service
is associated with the traditional SysV init system, which was widely used in older Linux distributions.
systemctl
provides a more comprehensive and feature-rich set of commands for managing services and other aspects of the system, such as sockets, timers, and targets.
service
offers a more basic set of commands primarily focused on starting, stopping, and restarting services.
systemctl commands :
systemctl start <service-name>
systemctl stop <service-name>
systemctl restart <service-name>
systemctl enable <service-name>
systemctl disable <service-name>
systemctl status <service-name>
service commands :
service <service-name> start
service <service-name> status
service <service-name> stop
service <service-name> restart
Conclusion:
In summary, systemctl
is the preferred choice for managing services on modern Linux distributions using the systemd
init system. It offers more advanced features and flexibility compared to the more basic service
utility associated with the older SysV init system. If you are using a distribution that utilizes, it is recommended to use systemctl
for service management.