# #Day07 of 90DayOfDevOps

1. ### What is a Package Manager in Linux?
    

A package manager in Linux is a tool that automates software installation, upgrading, configuration, and removal by retrieving package files, resolving dependencies, and ensuring correct installation, with common examples including APT, YUM, DNF, and Pacman.

2. ### What is a Package?
    

A package in Linux software management is a compressed file archive containing all necessary files for installing software, including executables, libraries, configuration files, scripts, and metadata for version, description, and dependencies, which package managers use to automate software installation and management.

3. ### Different Kinds of Package Managers.
    

There are several kinds of package managers in Linux, each designed to work with specific distributions or package formats. Here are some of the most common ones:

1. **APT (Advanced Package Tool)**: Used primarily in Debian-based distributions like Ubuntu. It handles .deb packages and is known for its ease of use and powerful dependency resolution.
    
2. **YUM (Yellowdog Updater, Modified)**: Used in RPM-based distributions like CentOS and older versions of Fedora. It manages .rpm packages and is known for its ability to handle complex package management tasks.
    
3. **DNF (Dandified YUM)**: The next-generation version of YUM, used in Fedora and newer versions of Red Hat-based distributions. It offers improved performance and better dependency management.
    
4. **Pacman**: The package manager for Arch Linux and its derivatives. It is known for its simplicity and speed, managing .pkg.tar.zst packages.
    
5. **Zypper**: Used in openSUSE and SUSE Linux Enterprise. It is known for its powerful dependency resolution and support for multiple repositories.
    
6. **Portage**: The package management system used by Gentoo Linux. It is a source-based package manager, allowing users to compile packages from source for optimization.
    
7. **Snap**: A package management system developed by Canonical for installing software across various Linux distributions. It uses containerized packages called snaps.
    
8. **Flatpak**: A universal package management system that allows applications to run on any Linux distribution. It focuses on application isolation and security.
    
9. **Nix**: A purely functional package manager that is part of the NixOS project. It is known for its reproducibility and ability to manage multiple versions of packages.
    

Each package manager has its own strengths and is chosen based on the specific needs and preferences of the distribution and its use

### Task 1:

1. **Install Docker and Jenkins on your system from your terminal using package managers.**
    
    Answer
    
    1. **First-Installing Docker**
        
    
    1. Update the package list and install required packages:
        
    
    * `sudo apt update`
        
    * `sudo apt install apt-transport-https ca-certificates curl software-properties-common`
        
    
    2. Add Docker’s official GPG key:
        
        * `curl -fsSL [`[`https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg)`](https://download.docker.com/linux/ubuntu/gpg]\(https://download.docker.com/linux/ubuntu/gpg\)) `| sudo apt-key add -`
            
    3. Add the Docker APT repository:
        
        * `sudo add-apt-repository "deb [arch=amd64] [`[`https://download.docker.com/linux/ubuntu](https://download.docker.com/linux/ubuntu)`](https://download.docker.com/linux/ubuntu]\(https://download.docker.com/linux/ubuntu\)) `$(lsb_release -cs) stable"`
            
    4. Update the package list again:
        
        * `sudo apt update`
            
    5. Install Docker:
        
        * `sudo apt install docker-ce`
            
    6. Check Docker installation:
        
        * `sudo systemctl status docker`
            
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728620332505/8c72ea0d-7638-4486-9751-8736ed03984c.png align="center")
    
    **  
    second-Installing Jenkins:**
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728620752782/384ad40d-9325-4d67-a656-276e444776ad.png align="center")

**Note:** First, check whether JAVA is installed or not.

```bash
java -version
```

if you have not installed

```bash
   sudo apt install default-jre
```

* Start Jenkins:
    
    ```bash
       sudo systemctl start jenkins
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728620988032/78061501-5941-4660-80a9-d35e022076a8.png align="center")
    
    2. Write a small blog or article on how to install these tools using package managers on Ubuntu and CentOS.
        
        ## Installing Docker and Jenkins on Ubuntu and CentOS
        
        ### Installing Docker
        
        #### On Ubuntu:
        
        1. Begin by updating the package list and installing necessary packages to allow apt to use a repository over HTTPS.
            
        2. Add Docker’s official GPG key to ensure the authenticity of the packages.
            
        3. Set up the Docker APT repository to access Docker packages.
            
        4. Update the package list again to include Docker packages from the newly added repository.
            
        5. Install Docker Community Edition.
            
        6. Verify the Docker installation by checking its status.
            
        
        #### On CentOS:
        
        1. Install required packages to manage repositories and dependencies.
            
        2. Add the Docker repository to the system to access Docker packages.
            
        3. Install Docker Community Edition.
            
        4. Start the Docker service to begin using it.
            
        5. Enable Docker to start automatically at boot time.
            
        
        ### Installing Jenkins
        
        #### On Ubuntu:
        
        1. Ensure Java is installed, as Jenkins requires it to run.
            
        2. Add the Jenkins repository key to verify the packages.
            
        3. Add the Jenkins repository to the system to access Jenkins packages.
            
        4. Update the package list and install Jenkins.
            
        5. Start the Jenkins service.
            
        6. Enable Jenkins to start automatically at boot time.
            
        
        #### On CentOS:
        
        1. Install Java if it is not already installed, as it is required for Jenkins.
            
        2. Add the Jenkins repository to the system to access Jenkins packages.
            
        3. Import the Jenkins repository key to verify the packages.
            
        4. Install Jenkins.
            
        5. Start the Jenkins service.
            
        6. Enable Jenkins to start automatically at boot time.
            
        
        By following these steps, you can successfully install Docker and Jenkins on both Ubuntu and CentOS systems using their respective package managers.
        
        ### **Task 2:**
        
        1. **Check the status of the Docker service on your system (ensure you have completed the installation tasks above)**
            
            ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728621759398/d0e504ea-3d55-4742-b4b0-cf24ea5d9171.png align="center")
            
            2. **Manage Jenkins Service:**
                
            
            * Stop the Jenkins service and post before and after screenshots.
                
                ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728622364233/a85856bb-843b-44d3-a9de-6c402b78e020.png align="center")
                
                3. **Read About Systemctl vs. Service:**
                    
                    In Linux, both `systemctl` and `service` are used to manage services, but they are part of different init systems.
                    
                    1. **systemctl**:
                        
                        * Part of the `systemd` init system, which is the default in many modern Linux distributions like Ubuntu, Fedora, and CentOS 7 and later.
                            
                        * Provides a unified interface to manage services, sockets, devices, and more.
                            
                        * Offers advanced features like parallel service startup, on-demand starting of daemons, and snapshotting of the system state.
                            
                        * Common commands include:
                            
                            * `systemctl start <service>`: Starts a service.
                                
                            * `systemctl stop <service>`: Stops a service.
                                
                            * `systemctl restart <service>`: Restarts a service.
                                
                            * `systemctl status <service>`: Checks the status of a service.
                                
                            * `systemctl enable <service>`: Enables a service to start at boot.
                                
                            * `systemctl disable <service>`: Disables a service from starting at boot.
                                
                    2. **service**:
                        
                        * Part of the older `SysVinit` system, which was used in older Linux distributions.
                            
                        * Provides a simpler interface for managing services.
                            
                        * Common commands include:
                            
                            * `service <service> start`: Starts a service.
                                
                            * `service <service> stop`: Stops a service.
                                
                            * `service <service> restart`: Restarts a service.
                                
                            * `service <service> status`: Checks the status of a service.
                                
                    
                    In summary, `systemctl` is more feature-rich and is used in systems running `systemd`, while `service` is used in systems running `SysVinit`. Most modern Linux distributions have transitioned to `systemd`, making `systemctl` the more commonly used tool.
                    
                    ### Additional Tasks
                    
                4. **Automate Service Management:**
                    
                    * Write a script to automate the starting and stopping of Docker and Jenkins services.
                        
                        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728624837086/192aa4fe-c4a4-4b14-b005-6bf0b9178607.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/v1728625182810/99759929-8362-40b6-a513-415b6df6fa75.png align="center")
                            
                            Disable Jenkins from starting on boot
                            
                            ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728625359357/305e90e1-e8e1-4181-b7da-a16d3266732a.png align="center")
                            
                            6. **Analyze Logs:**
                                
                                * Use journalctl to analyze the logs of the Docker and Jenkins services. Post your findings.
                                    
                                    **Answer**
                                    
                                * Docker Logs:
                                    
                                    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728625705772/28e77463-a578-4c10-b186-1f1b849b8ce6.png align="center")
                                    
                                    * Jenkins Logs:
                                        
                                        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728625773780/e2d8c4fc-03ec-493d-8841-2da28a3b568d.png align="center")
                                        
                                        ## **Conclusion**
                                        
                                        Linux package managers and systemd (with systemctl) form the backbone of software and service management in modern Linux distributions. Package managers ensure that software installations are handled smoothly and consistently, managing dependencies and updates efficiently. Meanwhile, systemd and systemctl provide robust tools for controlling and managing system services, enhancing system reliability and maintainability. Understanding these tools is crucial for effective Linux system administration.
                                        
                                        HAPPY LEARNING!
