- DevOps Lifecycle -Newspaper WordPress Theme
90DaysOfDevOpsDay 7 Task - Understanding package manager and systemctl

Day 7 Task – Understanding package manager and systemctl

#90DaysOfDevopsChallenge

1. Pacakage 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 lines tool like apt-get or Pacman.

What is a Package?

A package is usually referred to 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.

How does the package manager work?

The package manager is a generic concept and it’s not exclusive to Linux. You’ll often find package managers for different software or programming languages. There is a PIP package manager just for Python packages.

Almost all Linux distributions have software repositories which is a collections of software packages. Yes, there could be more than one repository. The repositories contain software packages of a different kinds.

Repositories also have metadata files that contain information about the packages such as the name of the package, version number, description of the package and the repository name etc. This is what you see if you use the apt show command in Ubuntu/Debian.

Your system’s package manager first interacts with the metadata. The package manager creates a local cache of metadata on your system. When you run the update option of the package manager (for example apt update), it updates this local cache of metadata by referring to metadata from the repository.

When you run the installation command of your package manager (for example apt install package_name), the package manager refers to this cache. If it finds the package information in the cache, it uses the internet connection to connect to the appropriate repository and downloads the package first before installing on your system.

A package may have dependencies. Meaning that it may require other packages to be installed. The package manager often takes care of the dependencies and installs it automatically along with the package you are installing.

Types of Package Managers:

  • 1. DPKG – Debian Package Management System
  • APT (Advanced Packaging Tool) :It is a very popular, free, powerful, and more so, useful command line package management system that is a front end for the dpkg package management system.Users of Debian or its derivatives such as Ubuntu and Linux Mint should be familiar with this package management tool.
  • Aptitude Package ManagerThis is also a popular command line front-end package management tool for the Debian Linux family, it works similarly to APT . It was initially built for Debian and its derivatives but now its functionality stretches to the RHEL family.
  • 2. RPM (Red Hat Package Manager)
  • YUM (Yellowdog Updater, Modified)It is an open-source and popular command line package manager that works as an interface for users to RPM. You can compare it to APT under Debian Linux systems, it incorporates the common functionalities that APT has.
  • 3. Pacman Package Manager – Arch Linux
  • 4. Zypper Package Manager – openSUSE
  • 5. Portage Package Manager – Gentoo

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

Jenkins:

To install Jenkins you first have to install java. So this is some steps to install java:

Initially update all packages used in the below command. NOTE: I’m showing here for Ubuntu operating system.

sudo apt update

Depending on which Java version you want to install, Java 8 or 11, run one of the following commands:

To install OpenJDK 8, run:

sudo apt install openjdk-8-jdk -y

To install OpenJDK 11, run:

sudo apt install openjdk-11-jdk -y

Add Jenkins Repository

The version of Jenkins included with the default Ubuntu packages is often behind the latest available version from the project itself. To ensure you have the latest fixes and features, use the project-maintained packages to install Jenkins.

First, add the repository key to your system:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg

The gpg --dearmor command is used to convert the key into a format that apt recognizes.

Next, let’s append the Debian package repository address to the server’s sources.list:

sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

The [signed-by=/usr/share/keyrings/jenkins.gpg] portion of the line ensures that apt will verify files in the repository using the GPG key that you just downloaded.

After both commands have been entered, run apt update so that apt will use the new repository.

sudo apt update

Finally, install Jenkins and its dependencies:

sudo apt install jenkins

Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.

Starting Jenkins

now that Jenkins is installed, start it by using systemctl:

sudo systemctl start jenkins.service

Since systemctl doesn’t display status output, we’ll use the status command to verify that Jenkins started successfully:

sudo systemctl status jenkins

If everything went well, the beginning of the status output shows that the service is active and configured to start at boot:

you have completed the installation stage and can continue with configuring Jenkins.

Docker installation:

step 1: sudo apt update -y

step 2: sudo apt install docker.io -y

step 3: docker –version

step 4: systemctl status docker [ to check if docker is in the active state]

systemctl and systemd

systemctl is used to examine and control the state of the “systemd” system and service manager.

systemd is a system and service manager for Unix-like operating systems(most of the distributions, not all).

4. stop the service Jenkins and post before and after screenshots

Jenkins active status Screenshot:

Jenkins stop Screenshot :

Read about the commands systemctl vs service

The Service command looks up the script to run at the path /etc/init.d/SCRIPT. It then runs the script, passing the COMMAND unchanged as the arguments. The service command guarantees a predictable running environment by removing most of the variables and setting the root path as the current working directory.

eg: sudo service jenkins start

The systemctl command interacts with the SystemD service manager to manage the services. Contrary to the service command, it manages the services by interacting with the SystemD process instead of running the init script.

To start, stop, and restart a process, we can run the commands with systemctl .

eg: sudo systemctl start docker

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe Today

GET EXCLUSIVE FULL ACCESS TO PREMIUM CONTENT

SUPPORT NONPROFIT JOURNALISM

EXPERT ANALYSIS OF AND EMERGING TRENDS IN CHILD WELFARE AND JUVENILE JUSTICE

TOPICAL VIDEO WEBINARS

Get unlimited access to our EXCLUSIVE Content and our archive of subscriber stories.

Exclusive content

- Advertisement -Newspaper WordPress Theme

Latest article

More article