Day 7 Understanding package manager and systemctl

Day 7 Understanding package manager and systemctl

Understanding package manager and systemctl

In Linux, package management is essential for managing software and maintaining the stability and security of the system. Different Linux distributions have their own package management systems, such as Debian-based systems that use the .deb package format and RPM-based systems that use the .rpm format.

One of the most popular package management systems in Linux is apt, which stands for Advanced Packaging Tool. It is the default package manager for Debian-based systems, including Ubuntu, and is used to manage software installation, removal, and upgrades.

Another popular package manager is yum, which stands for Yellowdog Updater Modified. It is the default package manager for RPM-based systems, including Red Hat Enterprise Linux (RHEL), CentOS, and Fedora.

With package management, system administrators can easily install and update software packages without the need to manually download and compile source code. Package managers also provide dependency tracking, which ensures that all required libraries and dependencies are installed along with the package.

In addition to the command-line package managers, there are also graphical front-ends available, such as Synaptic for apt and DNFdragora for yum. These front-ends provide a user-friendly interface for managing packages and dependencies.

Overall, package management is a crucial aspect of Linux system administration, and understanding the various package managers and how to use them effectively is essential for maintaining a stable and secure Linux system.

Q1: What is a package manager in Linux?

A package manager is a tool in Linux for installing, removing, upgrading, and managing software packages on an operating system, either through a GUI or command-line interface. It is responsible for automating the process of installing, upgrading, configuring, and removing software packages on a system. The package manager provides a central repository of software packages, which can be easily searched, downloaded, and installed with the click of a button or the execution of a command.

Q2: What is a package?

A package is a collection of files and data that make up a software application, library, or another software component. In Linux, packages are often used for distributing and installing software, and they can contain everything from executable code to documentation and configuration files. The package manager handles the installation and removal of packages on the system, as well as any dependencies required by the software. Each package has a unique name and version number, and the package manager keeps track of which packages are installed and which versions are currently in use.

Q3:Different kinds of package managers?

Package managers differ based on the packaging system used by the Linux distribution. Here are some popular package managers used in Linux:

  1. dpkg: dpkg is a package manager used by Debian-based Linux distributions, such as Debian and Ubuntu. It installs, removes, and provides information about packages and their dependencies.

  2. apt: Advanced Package Tool (apt) is a high-level package manager used by Debian-based Linux distributions. It provides a user-friendly interface and handles dependencies automatically.

  3. RPM: RPM (Red Hat Package Manager) is a package manager used by Red Hat-based Linux distributions, such as Red Hat Enterprise Linux (RHEL), CentOS, and Fedora. RPM installs remove and manage packages and their dependencies.

  4. YUM: Yellowdog Updater Modified (YUM) is a command-line package manager used by Red Hat-based Linux distributions. It manages packages and their dependencies and automatically resolves dependencies when installing or removing packages.

  5. DNF: DNF (Dandified YUM) is a next-generation version of YUM, and it is used by Fedora and CentOS 8 and later versions.

  6. Pacman: Pacman is the package manager used by Arch Linux and its derivatives. It is a command-line package manager that can handle dependencies and perform system upgrades.

There are other package managers available for Linux, but these are some of the most popular ones used in the Linux community.

Q4: Install docker and Jenkins in your system from your terminal using package managers.

--> Docker installation in centos 7.

Step 01:

let’s update the package database:

Use the command to update sudo yum check-update

or else u can become Root by using the command su - and enter the Root password.

Then use the command to update yum update. It will take some time to update depending on your internet speed. Once the update completes follow the step 2 process.

Step 2:

Now run this command.

--> curl -fsSL get.docker.com | sh

After installation has completed, start the Docker daemon:

--> systemctl start docker

Verify that it’s running:

--> systemctl status docker

--> Jenkins installation in centos 7.

Step 03:

Jenkins installation

--> cd ~

--> wget -O /etc/yum.repos.d/jenkins.repo pkg.jenkins-ci.org/redhat-stable/jenkins.repo

--> rpm --import pkg.jenkins-ci.org/redhat-stable/jenkins-ci..

--> yum install jenkins

Now start the Jenkins service and set it to run at boot time.

--> systemctl start jenkins.service

--> sudo systemctl enable jenkins.service

You will need to allow the inbound traffic on port 8080 to access the Jenkins.

--> firewall-cmd --zone=public --permanent --add-port=8080/tcp

--> firewall-cmd --reload

Now, access the Jenkins using the below address from your web browser:

--> your_server_IP_or_domain_name:8080

(5)systemctl and systemd.

The systemctl command is a systemd utility used to manage services, get information about service unit files and service states, and therefore a useful utility to know for managing services on the server while systemd is an array of components for Linux OS.

systemctl is used to examine and control the state of “systemd” system and service manager. systemd is system and service manager for Unix like operating systems(most of the distributions, not all).

The systemctl command in a Linux utility is used to manage the systemd service and service manager.
systemd is an init system and system manager, It runs with PID 1 and it is the one responsible for starting the rest of the system.

The syntax is as follows:

--> systemctl [OPTIONS...] COMMAND ...

* Starting, stopping, restarting, reloading services.

Make sure you are logged in as Root. In case you are not logged in as Root then use sudo command

To start a service, apache2

--> systemctl start mariadb.service

To stop the service we write:

--> systemctl stop mariadb.service

To restart the service

--> systemctl restart mariadb.service

To reload the service

--> systemctl reload mariadb.service

To check the status of the service

--> systemctl status mariadb.service

To enable the service

--> systemctl enable mariadb.service

To disable the service

--> systemctl disable mariadb.service

(6) Read about the commands systemctl vs service

eg. systemctl status docker vs service docker status

--> systemctl is a command-line utility used to control and manage the systemd system and service manager on Linux systems. It can be used to start, stop, and restart services, enable and disable them to start at boot, and check the status of services.

--> service is a more generic utility that is used to manage services on a wider range of systems, including those that do not use systemd . If your system uses systemd, you should use systemctl to manage services. If your system does not use **systemd ,**or if you are not sure, you can use service as a more generic utility.

systemctl commands :

  • systemctl start docker

  • systemctl stop docker

  • systemctl restart docker

  • systemctl enable docker

  • systemctl disable docker

  • systemctl status docker

service commands :

  • service docker start

  • service docker status

  • service docker stop

  • service docker restart

Thanks