# Day-07 Task: Understanding Package Manager and Systemctl

### 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`.

You’ll often find me using the term ‘package’ in tutorials and articles. To understand a package manager, you must understand what a package is.

### What is a Package?

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

### Different Kinds of Package Managers

Package managers differ based on the packaging system, but the same packaging system may have more than one package manager.

For example, RPM has Yum and DNF package managers. For DEB, you have `apt-get`, aptitude command-line-based package managers.

## Tasks

1. **Install Docker and Jenkins:**
    
    * Install Docker and Jenkins on your system from your terminal using package managers.
        
    * Docker installation proof :
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975294850/f1425fe7-1f91-4820-ae75-a504c1491d68.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975311624/fff7364b-ee80-4ea7-8066-3e25e3cd26ab.png align="center")
        
    * Jenkins installation proof :
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975364261/1a10c67d-c248-4426-92e5-74401df4a8d4.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975372634/f4c77807-fee4-4f35-b986-8ddedd55ccb3.png align="center")
        
2. **Write a Blog or Article:**
    
    * Write a small blog or article on how to install these tools using package managers on Ubuntu and CentOS.
        
    * Checkout blog here: [Docker and Jenkins Installation](https://amitabhdevops.hashnode.dev/docker-and-jenkins-installation)
        

### 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 distributions, but not all).

## Tasks

1. **Check Docker Service Status:**
    
    * Check the status of the Docker service on your system (ensure you have completed the installation tasks above).
        
    
    **Answer**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975390377/02797c54-a8ff-4991-aafe-f3d3eed76720.png align="center")
    
2. **Manage Jenkins Service:**
    
    * Stop the Jenkins service and post before and after screenshots.
        
    * Before stopping:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975409547/603ee716-8587-43d6-90cd-91b27068fdbe.png align="center")
        
    * After stopping:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975402388/ff18b32a-2a22-4bee-ad24-8095e9317aea.png align="center")
        
3. **Read About Systemctl vs. Service:**
    
    * Read about the differences between the `systemctl` and `service` commands.
        
    * Example: `systemctl status docker` vs. `service docker status`.
        
    
    **Answer**
    
    * For detail understanding of Systemctl and Service, read this blog: [Understanding the Differences Between Systemctl and Service Commands in Linux](https://amitabhdevops.hashnode.dev/understanding-the-differences-between-systemctl-and-service-commands-in-linux)
        

### Additional Tasks

4. **Automate Service Management:**
    
    * Write a script to automate the starting and stopping of Docker and Jenkins services.
        
    * Stopped both Docker and Jenkins:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975429016/ac0f6262-773b-42a4-abb1-1e593270d7b8.png align="center")
        
    * stop\_services.sh:
        
        ```bash
        #!/bin/bash
        
        <<Info
        Author : Amitabh Soni
        date : 30/11/24
        description : This script is used to automate the stopping of Docker and Jenkins services.
        Info
        
        # Stopping Docker service
        sudo systemctl stop docker
        
        # Stopping Jenkins service
        sudo systemctl stop jenkins
        
        # Checking if the previous commands ran successfully
        if [[ $? -eq 0 ]]; then
           echo "Docker and Jenkins services have been stopped successfully."
        else
           echo "An error occurred while stopping Docker and Jenkins services."
        fi
        ```
        
    * start\_services.sh:
        
        ```bash
        #!/bin/bash
        
        <<Info
        Author : Amitabh Soni
        date : 30/11/24
        description : This script is used to automate the starting of Docker and Jenkins services.
        Info
        
        # Starting Docker service
        sudo systemctl start docker
        
        # Starting Jenkins service
        sudo systemctl start jenkins
        
        # Checking if the previous commands ran successfully
        if [[ $? -eq 0 ]]; then
            echo "Docker and Jenkins services have been started successfully."
        else
            echo "An error occurred while starting Docker and Jenkins services."
        fi
        ```
        
    
    1. Verifying Docker and Jenkins services stopped or not:
        
        * Docker:
            
            ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975454688/e3d25875-a3df-45ef-98d5-a604efed6fd7.png align="center")
            
        * Jenkins:
            
            ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975468071/b0d6753c-31d4-4150-8dfb-97ad2bf6442d.png align="center")
            
5. **Enable and Disable Services:**
    
    * Use `systemctl` to enable Docker to start on boot and disable Jenkins from starting on boot.
        
    
    **Answer**
    
    * Enable Docker to start on boot:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975478501/c0951d47-45f8-46df-aced-a89995ba2048.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975486674/0a8d7243-045c-4f9f-8b8c-551f8f1915f8.png align="center")
        
    * Disable Jenkins from starting on boot:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975500230/18521811-857b-4a8a-b0e8-3d3610c8da5e.png align="center")
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975506151/fcb30e51-d066-42bd-b2df-591c30c855d6.png align="center")
        
6. **Analyze Logs:**
    
    * Use `journalctl` to analyze the logs of the Docker and Jenkins services. Post your findings.
        
    
    **Answer**
    
    * Docker last 10 logs:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975521179/1ea29c23-aa52-4b07-b097-d3dd5028f094.png align="center")
        
    * Jenkins last 10 logs:
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732975528147/d6df17e7-3dfd-4550-9320-5a9be75c635a.png align="center")
