Day 7 Task: Understanding Package Manager and Systemctl

Vibhuti JainVibhuti Jain
4 min read

Package management in Linux is the process of installing, updating, configuring, and removing software packages on a Linux system. Different Linux distributions use different package management systems, but the basic concepts are similar across all systems.

Key Concepts in Package Management

  1. Package: A package is a compressed archive containing all the files needed for a piece of software, including binaries, libraries, configuration files, and documentation.

  2. Package Manager: A package manager is a tool that automates the process of managing packages. It handles the installation, upgrade, and removal of software packages, along with resolving dependencies (other packages required for a package to work).

Common Package Managers

  1. APT (Advanced Package Tool) - Used by: Debian, Ubuntu, and their derivatives.

Key Commands:

Update package list:

$sudo apt update

Install a package:

$sudo apt install <package_name>

Upgrade all installed packages:

$sudo apt upgrade

Remove a package:

$sudo apt remove <package_name>

Search for Packages:

$sudo search <package_name>

Get information about a package:

$sudo show <package_name>
  1. YUM (Yellowdog Updater, Modified) / DNF (Dandified YUM) - Used by: Red Hat, CentOS, Fedora

Package Format: .rpm

Key Commands (DNF is the newer version of YUM):

Update package list:

$sudo yum check-update
$sudo dnf check-update

Install a package:

$sudo yum install <package_name>
$sudo dnf install <package_name>

Upgrade all installed packages:

$sudo yum update
$sudo dnf upgrade

Remove a package:

$sudo yum remove <package_name>
$sudo dnf remove <package_name>

Search for a package:

$sudo yum search <package_name> 
$sudo dnf search <package_name>

Get information about a package:

$sudo yum info <package_name>
$sudo dnf info <package_name>
  1. Difference between Update and Upgrade

    Update

    • Purpose: The update command is used to refresh the package list on your system. It fetches the latest information about available packages and their versions from the repositories configured on your system.

    • What It Does:

      • It does not actually install or upgrade any packages.

      • It simply updates the package manager's local database with the most recent versions and dependencies available in the repositories.

    $sudo apt update
  • This command will download the latest package lists from the repositories and update the local database. It’s a preparatory step before upgrading packages.

  • When to Use:

    • Use update regularly to ensure your package manager has the latest information about available packages.

    • Always run update before running an upgrade to make sure you’re upgrading to the latest versions.

Upgrade

  • Purpose: The upgrade command is used to actually install the newest versions of all the packages currently installed on your system.

  • What It Does:

    • It checks the versions of the installed packages against the versions available in the repositories (after running update).

    • It upgrades installed packages to their newest versions if available.

    • It does not remove any packages or install new packages that are not already installed (unless required for the upgrade).

    $sudo apt upgrade

When to Use:

  • Use upgrade after running update to keep your system’s software up-to-date.

Install Docker and Jenkins:

$sudo apt install docker.io 
$sudo apt install jenkins
  1. Systemd and Systemctl Overview

    Systemctl ( System Control ) - Systemctl is the command-line tool that allows administrators to control and manage services, check their status, and configure how services start and stop. It is an essential tool for working with systemd.

    Common Systemctl Commands:

    Start a service:

     $sudo systemctl start service_name
    

    Stop a service:

     $sudo systemctl stop service_name
    

    Restart a service:

     $sudo systemctl restart service_name
    

    Enable a service:

     $sudo systemctl enable service_name
    

    Disable a service:

     $sudo sysytemctl disable service_name
    

    Checking status of a service:

     $sudo systemctl status service_name
    

    Manganing the system:

    Reboot the system:

     $sudo systemctl reboot
    

    shutdown the system:

     $sudo systemctl poweroff
    

    What is Systemd?

      • Systemd is a system and service manager for Linux operating systems. It is responsible for initializing the system (booting), managing services (such as starting, stopping, and restarting services), and maintaining the overall system state.

        • It was introduced to replace older init systems like SysVinit and Upstart, providing a more efficient, standardized, and feature-rich way to manage system processes and services.

          Features:

          • Parallel Startup: Systemd can start services in parallel, speeding up the boot process.

          • On-Demand Service Starting: Services can be started on-demand when needed, rather than all at boot time.

          • Dependency Management: Systemd manages service dependencies, ensuring that services are started in the correct order.

          • Unit Files: Systemd uses unit files to define services, mount points, devices, and other system resources.

          • Logging: Systemd includes the journald service, which provides centralized logging.

0
Subscribe to my newsletter

Read articles from Vibhuti Jain directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vibhuti Jain
Vibhuti Jain

Hi, I am Vibhuti Jain. A Devops Tools enthusiastic who keens on learning Devops tools and want to contribute my knowledge to build a community and collaborate with them. I have a acquired a knowledge of Linux, Shell Scripting, Python, Git, GitHub, AWS Cloud and ready to learn a lot more new Devops skills which help me build some real life project.