Day-07: Understanding package manager and systemctl.

Day-07: Understanding package manager and systemctl.

What is a package manager in Linux?

A package manager is a software tool used in Linux and other Unix-based operating systems to manage the installation, removal, and upgrading of software packages. The package manager can be a graphical application like a software center or a command line tool like apt-get or pacman.

What is a package?

A package refers to a collection of files and metadata that are bundled together in a specific format for easy installation and management by a package manager.A package typically contains the software code, documentation, configuration files, and other necessary files required for a particular software program or application to run on a Linux system.

Different kinds of package managers.

Package Managers differ based on packaging system but same packaging system may have more than one package manager.

Examples of package managers in Linux include:

  • Advanced Package Tool (APT) used by Debian and its derivatives like Ubuntu

  • Yellowdog Updater, Modified (YUM) used by Red Hat and its derivatives like CentOS and Fedora.

  • Pacman used by Arch Linux.

  • Zypper used by SUSE Linux.

You have to install docker and jenkins in your system from your terminal using package managers.

For UBUNTU: Steps to install docker

1.Update the package database with the following command:

#sudo apt-get update

2.Install the necessary packages with the following command:

#sudo apt-get install docker.io

3.Install all the dependency packages using the following command :

#sudo snap install docker

4.Check the installed version of docker:

#docker --version

For Ubuntu: Steps to install jenkins

1. Update ubuntu:

#sudo apt-get update

2. Since Jenkins is written, install Java:

#sudo apt install openjdk-11-jdk -y

3. Add keys:

#curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null

4. Add the Jenkins software repository to the source list and provide the authentication 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

5. Update packages again:

#sudo apt-get update

6. Finally, install Jenkins and its dependencies:

#sudo apt-get install jenkins

7. To check if Jenkins is installed and running, run the following command:

#sudo systemctl status jenkins

systemctl and systemd

systemctl is a command-line utility in Linux systems that is used to control and manage the system's services, including starting, stopping, enabling or disabling them, checking their status, and viewing their logs.

Systemd is a system and service manager for Linux operating systems. It is responsible for managing the startup and shutdown of the system, as well as managing system processes and services.

check the status of docker service in your system by using systemcl command.

check the status of jenkins service in your system by using systemcl command.

Stop the jenkins service

systemctl vs service

Both systemctl and service are commands used in Linux for managing system services, but there are some differences between them.

service is a command used to start, stop, restart, and check the status of system services. The syntax for using the service command is as follows:

#sudo service <service-name> <action>

On the other hand, systemctl is a more modern command that is part of the systemd init system, which is the default system and service manager in many modern Linux distributions.The syntax for using the systemctl command is as follows:

#sudo systemctl <action> <service-name>

One major difference between systemctl and service is that systemctl can manage user services as well as system services, while service is limited to managing system services.

Overall, while both systemctl and service can be used for managing system services in Linux, systemctl is generally more powerful and versatile due to its integration with the systemd init system.

Thank you for reading this article! :-)