Hello Everyone, Today we are learning about package manager and systemctl .
What is a Package Manager?
A package manager is a 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. A package manager works with packages, data within archive files, and software distributions.
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.
A package is a compressed archive that contains software, its files, and information needed for installation and management. It simplifies software distribution and installation on Linux systems.
Functions of Package Manager:
A software package can be defined as an archive file combining a computer program and essential metadata for development. The system program could be within the source code that has to be built and compiled first.
Packages include metadata like the name of the software, description of its objective, dependency list, vendor, and version number essential for the software to properly run.
Different kinds of package managers
Package Managers differ based on 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.
Distributions: Ubuntu, Debian, and Kali Linux
Commands: apt, apt-get, apt-cache
Package file format: .deb
APT acts as a front-end to the lower-level dpkg package manager, which is used for installing, managing, and providing information on
Distributions: RHEL/CentOS 8, Fedora 22, and later versions of both distributions
Commands: dnf, yum
Package file format: .rpm
simply DNF, Just like YUM, DNF provides a user-friendly interface to the RPM Package Manager (RPM) and has several enhancements including increased performance, faster dependency resolution, and more complete documentation for its API.
Distributions: RHEL/CentOS 7, Fedora 21, and earlier versions of both distributions
Package file format: .rpm
Yellowdog Updater, commonly known as YUM, is a package management tool for a variety of older RHEL-based distributions (such as CentOS 7) and older versions of Fedora. It provides an easy-to-use interface on top of the low-level functions available in the RPM Package Manager.
Install Docker and Jenkins in your system from the terminal using package managers.
Steps to install docker using package managers:
Install Docker: Docker is widely available for most Linux distributions. Here's how you can install Docker using the package manager for different distributions:
For Debian/Ubuntu-based distributions (using APT):
sudo apt update sudo apt install docker.io -y
For Red Hat/CentOS-based distributions (using YUM):
sudo yum install docker
For Fedora (using DNF):
sudo dnf install docker
Start and Enable Docker Service: After installing Docker, start and enable the Docker service to ensure it starts automatically upon system boot.
sudo systemctl start docker sudo systemctl enable docker docker --version
Steps to install Jenkins using Package Manager:
- Jenkins requires Java to be installed on the system. You can check if Java is already installed by running, If Java is not installed or the version is below 17, you can install it using your package manager. Here's how to install OpenJDK 17:
java --version sudo apt install -y openjdk-17-jdk
- Adding Jenkins Repository
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
- Import the key file
sudo rpm — import https://pkg.jenkins.io/redhat/jenkins.io.key
Update the system repository one more time. Updating refreshes the cache and makes the system aware of the new Jenkins repository.
sudo apt update
- Install Jenkins using the below command
sudo yum install jenkins
- After installing Jenkins, start and enable the Jenkins service to run it as a background process.
sudo systemctl start jenkins sudo systemctl enable jenkins
- To check the status whether the service started or not, use the below command
sudo systemctl status jenkins
Jenkins will be available on port 8080 by default. we should open port 8080 in our security group.
- we can access the Jenkins web interface by opening a web browser and navigating to
Now, Copy the path given there and get a password from the server.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Now you can choose to launch your Jenkins instance with the suggested plugins or choose to install only the plugins you need
9. Create your username and password credentials in Jenkins and save it
- Installation and configuration are completed and now you can start creating the Jenkins jobs.
systemctl and systemd:
systemctl is the command line tool used to control and manage the systemd system and service manager. It provides various commands to start, stop, restart, enable, and disable services, as well as other functionalities such as inspecting the status of services, displaying log messages, and managing system-level settings and configurations.
Here are a few examples of common tasks that can be performed using systemctl:
Start a service:
systemctl start <service-name>
Stop a service:
systemctl stop <service-name>
Restart a service:
systemctl restart <service-name>
Enable a service to start automatically at boot:
systemctl enable <service-name>
Disable a service from starting automatically at boot:
systemctl disable <service-name>
Check the status of a service:
systemctl status <service-name>
systemd is a Linux init system and system manager that is widely used in modern Linux distributions as the default init system. It provides a way to manage and control the various services that run on a Linux system, as well as other system-level functionality.
check the status of docker service in your system (make sure you completed the above tasks, else docker won’t be installed)
systemctl status docker
To stop the docker service:
sudo systemctl stop docker
Check the status of Jenkins service in your system:
sudo systemctl status jenkins
To stop the Jenkins service :
systemctl stop jenkins
3. Read about the commands systemctl vs service
systemctl and service are both tools used to manage and control services on a Linux system. However, they have some differences:
systemctl is the newer tool and is used on systems that use the Systemd init system, which is now widely adopted as the default init system for many popular Linux distributions, including Fedora, Red Hat Enterprise Linux, and Ubuntu.
service is the older tool and is used on systems that use the System V init system, which was the previous standard init system used in many popular Linux distributions.
systemctl provides more advanced features compared to service, such as the ability to manage units, which are the basic building blocks of Systemd. This allows you to manage not just services, but also other system components, such as sockets, devices, and mount points, with a unified interface.
service is limited to managing services only, and its syntax and options are not as advanced as those of systemctl.
Thank you, for your precious time in reading the article/blog.