Day 7 Task: Understanding package manager and systemctl

Ashwini SavareAshwini Savare
4 min read

What is a package manager in Linux?

In simpler words, 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 like apt-get or pacman.

πŸ”§ Key Functions:

  • Installation: πŸš€ Easily add new software to your computer. Just tell the package manager what you want, and it takes care of the rest!

  • Dependency Resolution: 🧩 Handles the connections between different software pieces. No worries about missing pieces; the package manager puts everything together for you.

  • Updates: πŸ”„ Keeps your software up-to-date. With a simple command, you can update all your programs or just the ones you choose.

  • Removal: πŸ—‘οΈ When you're done with a program, the package manager helps you remove it neatly, making sure nothing is left behind.

  • Information: πŸ“Š Get details about available software. Want to know more about a program? The package manager provides all the information you need.

πŸ‘‰ Examples of Package Managers:

  • APT (Advanced Package Tool): πŸ› οΈ Used by Ubuntu and other Debian-based systems.

  • YUM (Yellowdog Updater, Modified): 🌐 Common in Red Hat-based systems like Fedora and CentOS.

  • zypper: πŸŒ€ Found in openSUSE and SUSE Linux Enterprise.

  • Pacman: 🏹 The go-to for Arch Linux users.

Each package manager has its own way of doing things, but they all share the goal of making your Linux experience smooth and simple!

What is a packageπŸ“¦?

  • A package is a compressed archive that includes software, files, and installation information.

  • Used for convenient and standardized software distribution and management.

There are different package management systems used by various Linux distributions. Two commonly used package management systems are:

  1. Debian Package Management (APT): Used by Debian-based distributions such as Debian itself, Ubuntu, and their derivatives. The package files have a .deb extension.

    • Common package management commands include:

      • apt-get: πŸ“¦Command-line tool for handling packages.

      • dpkg: 🧰Low-level package management tool for Debian packages.

  2. Red Hat Package Management (RPM): Used by Red Hat-based distributions such as Red Hat Enterprise Linux (RHEL), CentOS, Fedora, and others. The package files have a .rpm extension.

    • Common package management commands include:

      • yum 🚫 (Yellowdog Updater, Modified): Used in older versions; it has been largely replaced by dnf.

      • dnf πŸ”„(Dandified YUM): Modern package manager for RPM-based distributions.

πŸ› οΈ Putting Knowledge into Practice: Installing Docker and Jenkins

Now that we've got a grasp of what package managers are and how they work let's put this knowledge into practice. Your tasks for today are to install Docker and Jenkins on your system using package managers. We'll cover installation on both Ubuntu and CentOS.

🐳 Installing Docker on Ubuntu/Debian-based systems

For Ubuntu/Debian-based systems:

# Update package list
sudo apt update
# Install Docker
sudo apt install docker.io

For CentOS/RHEL-based systems:

# Install Docker
sudo yum install docker

Install Jenkins:

For Ubuntu/Debian-based systems:

# Update package list
sudo apt update
sudo apt install openjdk-11-jdk
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update

# Install Jenkins
sudo apt install jenkins

For CentOS/RHEL-based systems:

sudo yum install java-11-openjdk
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install jenkins

After completing these installations, you'll have Docker and Jenkins up and running on your system, thanks to the power of package managers.

systemdandsystemctl in Linux 🐧

1. systemd:

  • πŸš€ Init System:systemd is like the captain of your computer, making sure everything starts smoothly.

  • πŸ› οΈ Service Manager: It's the supervisor for all the little workers (services) running on your system.

  • ⚑ Parallelization: Helps your system start things up faster by doing multiple tasks at the same time.

  • πŸ“œ Logging: Keeps a journal of what's happening on your system so you can check it later.

2. systemctl:

systemctl is a command-line tool that interacts with the systemd manager. It allows you to control services, view their status, enable or disable them, and more.

πŸš€ Commands:

  • startsystemctl start <service>: Press the "Start" button for a service.

  • stopsystemctl stop<service>: Hit "Stop" to halt a service.

  • restartsystemctl restart <service>: For the times you want to give a service a quick reset.

  • statussystemctl status<service>: Check what a service is up to.

  • enablesystemctl enable<service>: Tell a service to start automatically when you turn on your computer.

  • disablesystemctl disable<service>: Stop a service from auto-starting.

Here are some tasks to get you started:

  1. Check the status of the Docker service on your system:

    For Ubuntu/Debian-based systems:

     sudo systemctl start docker
     sudo systemctl enable docker
     sudo systemctl status docker
    

    For CentOS/RHEL-based systems:

     sudo systemctl start docker
     sudo systemctl enable docker
     sudo systemctl status docker
    
  2. Stop the Jenkins service and capture before and after screenshots to observe the service's status change.

To stop the Jenkins service, run the following command:

sudo systemctl stop jenkins

Before stopping Jenkins:

After stopping Jenkins server

Stay tuned for more exciting challenges and continue to build your DevOps expertise. πŸ’ͺπŸ”₯

Happy Learning! 😊

~Ashwini πŸ™ƒ

0
Subscribe to my newsletter

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

Written by

Ashwini Savare
Ashwini Savare

Hi there! I'm a passionate individual deeply fascinated by the world of cloud computing, DevOps practices, and AWS. As a dedicated cloud enthusiast, I immerse myself in the ever-evolving landscape of cloud technologies, staying up-to-date with the latest trends and advancements. I find immense joy in leveraging the power of cloud platforms, especially AWS, to design scalable and robust solutions that meet modern-day business needs. DevOps has captured my heart with its holistic approach to software development and operations. I firmly believe in the power of collaboration, automation, and continuous improvement to streamline the software delivery process. With my strong foundation in DevOps principles, I strive to bridge the gap between development and operations teams, fostering a culture of efficiency and innovation. Join me on this exhilarating expedition as we unravel the intricacies of cloud technologies, dive deep into DevOps practices, and unleash the true potential of AWS. Together, let's explore, learn, and empower one another to thrive in this ever-evolving tech landscape.