# 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 lines tool like apt-get or Pacman.

You’ll often find me using the term ‘package’ in tutorials and articles, To understand 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 in your system from your terminal using package managers
    

* To install Docker, first, update your system with the command
    
    `~ sudo apt-get install` <mark>sudo</mark> will provide you the root access. It will update your system to the latest.
    
* then install the Docker from the package
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679822150769/1150b835-bf7e-4380-bf43-700f36a746b6.jpeg align="center")

* check the docker version with `~ docker --version`
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679822314078/a076aedf-c4db-44e9-b761-f7a8057b4b43.jpeg align="center")

* To install Jenkins refers to [This Blog](https://www.trainwithshubham.com/blog/install-jenkins-on-aws).
    
* Update your system
    
    ```bash
    sudo apt update
    ```
    
    Install java
    
    ```bash
    sudo apt install openjdk-11-jre
    ```
    
    Validate Installation
    
    ```bash
    java -version
    ```
    
    It should look something like this
    
    ```bash
    openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2) OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)
    ```
    
    *Step - 2 Install Jenkins*
    
    Just copy these commands and paste them onto your terminal.
    
    ```bash
    curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.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 binary/ | sudo tee \  /etc/apt/sources.list.d/jenkins.list > /dev/null
    
    sudo apt-get update 
    
    sudo apt-get install jenkins
    ```
    
    Step -3 Start Jenkins
    
    ```bash
    sudo systemctl enable jenkins
    ```
    
    ```bash
    sudo systemctl start jenkins
    ```
    
    ```bash
    sudo systemctl status jenkins
    ```
    
    Step - 4 Open port 8080 from AWS Console:
    
* Or you can directly pull the Jenkins image from Docker Hub.
    

```bash
~ sudo docker pull jenkins/jenkins
```

Docker and Jenkins are two widely used tools in the software development industry. Docker is a containerization platform that allows developers to package and deploy applications with all of their dependencies, while Jenkins is a popular open-source automation server used for continuous integration and continuous deployment (CI/CD).

In this article, we have shown you how to install Docker and Jenkins on Ubuntu using package managers. Both of these tools are essential for any modern software development project, and their installation is relatively straightforward. We hope this guide has been helpful to you and that you can now successfully install and use these tools on your system.

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

## Tasks

1. check the status of the docker service in your system (make sure you completed the above tasks, else docker won't be installed)
    
    use `~ sudo systemctl status docker`
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679824105929/c2d89e5d-51f5-4eea-b4f5-e932337bdb15.jpeg align="center")

1. stop the service Jenkins and post before and after screenshots
    

Before:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679824338573/5cd35871-0dbf-4742-a484-4c224cb410e2.jpeg align="center")

use: ~ `sudo systemctl stop jenkins` to stop Jenkins service.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679824361751/bee6701d-b9c0-4555-9690-2bb9647a2bf3.jpeg align="center")

1. read about the commands systemctl vs service
    
    `systemctl` and `service` are two commands used in Linux-based operating systems for managing system services.
    
    `systemctl` is a command used to control the systemd system and service manager. It is used to start, stop, enable, disable, restart, and reload system services. With `systemctl`, you can manage the system services at boot time, control their status, and view their logs.
    
    Some of the commonly used commands with `systemctl` are:
    
    * `systemctl start <service_name>` - start a service
        
    * `systemctl stop <service_name>` - stop a service
        
    * `systemctl restart <service_name>` - restart a service
        
    * `systemctl enable <service_name>` - enable a service to start automatically at boot time
        
    * `systemctl disable <service_name>` - disable a service from starting automatically at boot time
        
    * `systemctl status <service_name>` - display the current status of a service
        
    * `systemctl reload <service_name>` - reload the configuration of a service
        
    
    `service` is another command used for managing system services in Linux-based operating systems. It is typically used in older versions of Linux or in situations where `systemctl` is not available. It can start, stop, and restart services on the system.
    
    Some commonly used `service` commands are:
    
    * `service <service_name> start` - start a service
        
    * `service <service_name> stop` - stop a service
        
    * `service <service_name> restart` - restart a service
        
    * `service <service_name> reload` - reload the configuration of a service
        
    
    It is important to note that the `service` command may not work on all Linux-based systems, particularly those that use systemd as the system and service manager. In such cases, you should use `systemctl` to manage system services.
    
    In summary, `systemctl` and `service` are both commands used for managing system services in Linux-based operating systems. `systemctl` is the preferred command on modern systems that use systemd, while `service` is used on older systems or in situations where `systemctl` is not available.
    

for code - [GitHub](https://github.com/SumitRamchandra/90DaysOfDevOps/tree/master/2023/day05)

Thanks for reading! Hope you find this helpful.

Happy learning!!! Suggestions are welcome.

~[Sumit](https://www.linkedin.com/in/sumit-ghorpade-425803129/)

Thank You - @[Shubham Londhe](@TrainWithShubham)
