Day- 7 : Understanding package manager and systemctl

Day- 7 : Understanding package manager and systemctl

Β·

7 min read

Introduction πŸ“š

Welcome to Day 7 of the thrilling #90DaysOfDevOps challenge. In this blog, we will embark on an exploration of the package manager and its essential tools, such as APT (Advanced Package Tool) πŸ› οΈ and YUM (Yellowdog Updater Modified) πŸ› οΈ, alongside delving into the significance of systemctl and systemd. Our primary objective will be to install Docker 🐳 and Jenkins πŸ—οΈ using package managers. For Docker installation, we shall configure the repository, while for Jenkins, we'll leverage APT on Ubuntu. Furthermore, we'll gain proficiency in checking the status of the Docker service, halting the Jenkins service, and comprehending the distinctions between systemctl and service commands. So, let's delve into this exciting journey and harness the potential of streamlined software management within the Linux environment! πŸš€

πŸ“¦ What is a package?

In Linux, a package is a software distribution format that contains all the necessary files and information πŸ“ƒ required to install and manage a specific piece of software. Packages typically include the executable binaries πŸ’Ύ, libraries πŸ“š, configuration files πŸ“, and documentation πŸ“„ needed to run the software on a Linux system 🐧.

🧰 What is a package manager in Linux?

In Linux, a package manager is a tool that automates the installation, updating, and removal of software packages. It simplifies software management by handling dependencies and ensures consistent and reliable installations across the system. Users can access a centralized repository to find and install software easily. Package managers enhance system stability and security by efficiently managing software components.

A package manager is a tool that is used to install, upgrade, manage and remove packages. It is responsible to manage dependencies and to track all installed packages.

πŸ› οΈ Different kinds of package managers

There are two popular package managers APT (Advanced Package Tool) and YUM (Yellowdog Updater Modified).

APT (Advanced Package Tool): APT is widely used in Debian-based distributions like Ubuntu and is known for its user-friendly command-line interface. This package manager simplifies the process of interacting with the package management system, making it easier for users to perform various operations. πŸ› οΈ

With APT, you can effortlessly install, update, and remove packages using simple commands:

  • To install a package: sudo apt-get install package_name

  • To update packages: sudo apt-get update followed by sudo apt-get upgrade

  • To remove a package: sudo apt-get remove package_name

One of the significant advantages of APT is its automatic resolution of package dependencies. When you install a package, APT ensures that all required dependencies are also installed, preventing any conflicts or issues.

YUM (Yellowdog Updater Modified): YUM is commonly used in Red Hat-based distributions like CentOS and Fedora. Similar to APT, YUM provides a command-line interface for managing packages, making it convenient for users to handle software installations. πŸ› οΈ

  • To install a package: sudo yum install package_name

  • To update packages: sudo yum update followed by sudo apt-get upgrade

  • To remove a package: sudo yum remove package_name

One of the key features of YUM is its ability to manage package dependencies seamlessly. When you install or update a package using YUM, it automatically resolves dependencies, ensuring that all required packages are downloaded and installed correctly.

πŸ” Understanding systemctl and systemd

In Linux, "systemctl" and "systemd" are essential tools that help manage how programs and services run on the computer. Imagine your computer is like a big orchestra, with many different musicians playing their instruments (which are the programs and services). "systemd" is like the conductor, coordinating and keeping everything in order.

"systemctl" is like a remote control that allows you to interact with the conductor (systemd). You can use "systemctl" to start or stop programs, check their status (whether they are running or not), and even enable them to start automatically when the computer boots up.

systemctl: Systemctl is a command-line utility used to manage system services in Linux distributions that adopt the systemd init system. Systemd is a system and service manager that provides advanced features such as process management, logging, and service dependencies.

Commands:

  • πŸ” sudo systemctl start service_name

  • πŸ› οΈ sudo systemctl stop service_name

  • πŸ”„ sudo systemctl restart service_name

  • πŸ”” sudo systemctl enable service_name

  • πŸ”• sudo systemctl disable service_name

For example, let's say you have a music player program on your computer. Using "systemctl," you can start the music player to play your favorite songs, stop it when you want the music to stop, or check if it's currently playing. "systemctl" also helps your computer manage all kinds of services, like web servers, email services, or even programs that run in the background to keep your system running smoothly.

🐳 Task 1: Installing Docker and Jenkins Using Package Managers

πŸš€ Time to apply our package manager expertise! We'll now install Docker and Jenkins on Ubuntu using package managers. Let's dive in and get our hands dirty! πŸ’»

β€’ Installing Docker on Ubuntu using APT

  1. Update the package lists: πŸ”„

      sudo apt update
    
  2. Install the Docker repository: πŸ“¦

      sudo apt-get install docker.io -y
    
  3. To check the version of the docker: πŸš€

      docker version
    

β€’ Installing Jenkins on Ubuntu using APT

To install Jenkins on Ubuntu using APT, follow these steps:

  1. Jenkins requires Java to run, so we'll update the Debian apt repositories, install OpenJDK 17, and check the installation with the commands:

      sudo apt update
      sudo apt install openjdk-17-jre
      java -version
    
  2. Next, let’s install the Jenkins Long-Term Support release by using the below commands:

      curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
        /usr/share/keyrings/jenkins-keyring.asc > /dev/null
      echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
        https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
        /etc/apt/sources.list.d/jenkins.list > /dev/null
      sudo apt-get update
      sudo apt-get install jenkins
    
  3. Start the Jenkins service:

       sudo systemctl start jenkins
    
  4. Enable Jenkins to start on system boot:

       sudo systemctl enable jenkins
    

Jenkins should now be installed and running on your Ubuntu system. You can access it by opening your web browser and navigating to http://localhost:8080. πŸŒπŸŽ‰

πŸ”¦ Task 2: Checking the Status of the Docker Service

Now that Docker is set up on your system, let's see how to check its status using the "systemctl" command.

To check the status of the Docker service, simply run this command: πŸ”

systemctl status docker

The output will show you important details about Docker, such as whether it's running, enabled, and any recent log entries related to its activity. This helps you ensure that Docker is up and running smoothly on your system. πŸ‘πŸš€

πŸ›‘ Task 3: Stopping the Jenkins Service

To stop the Jenkins service, you can use the following command:

sudo systemctl stop jenkins

Running this command will halt the Jenkins service, bringing it to a stop. It will no longer be running on your system until you start it again.

πŸ’‘ Difference between systemctl and service

systemctl and service are both commands used to manage services in Linux, but they have some differences in their functionality and usage.

systemctl:

  • systemctl is a more modern and πŸ›Έ powerful service management utility introduced with systemd, which is the default init system in many modern Linux distributions.

  • It provides ✨ extensive features for controlling services, including starting, stopping, restarting, enabling (starting at boot), disabling (not starting at boot), and checking the status of services.

  • Example: To check the status of the Docker service using systemctl, you would use the following command:

        systemctl status docker
    

service:

  • service is a legacy command used in init-based systems (SysVinit) to manage services.

  • It is still available in many Linux distributions for backward compatibility but is being phased out in favor of systemctl.

  • service provides a simpler interface for starting, stopping, and restarting services, but it has fewer features compared to systemctl. ⏳

  • Example: To check the status of the Docker service using service, you would use the following command: πŸ‘‡

        service docker status
    

πŸŽ‰ Conclusion πŸŽ‰

Congratulations on successfully completing Day 7 of the exhilarating #90DaysOfDevOps challenge! πŸš€ Today, we dived into the fascinating world of packages and package managers, understanding their vital role in the Linux ecosystem. πŸ“¦ By exploring various package managers and mastering systemctl and systemd, we have gained the confidence to effortlessly handle services. πŸ”„ With Docker and Jenkins seamlessly installed using package managers, we have embraced simplicity and automation in our journey. πŸ³πŸ”§ Now, you have the capability to monitor Docker's status and halt Jenkins with ease. πŸ“Š Furthermore, we have learned to differentiate between systemctl and service, ensuring proper and efficient service management. πŸ’‘ Keep up the fantastic work, and get ready for more thrilling adventures that lie ahead! πŸ’ͺ🌟

Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps πŸš€ by following me on Hashnode, LinkedIn linkedin.com/in/sahil-kamble-40898b208

Thank you for reading! πŸ™ Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.

Did you find this article valuable?

Support Sahil Kamble's blog by becoming a sponsor. Any amount is appreciated!

Β