# Understanding package manager and systemctl

## Package and Package Manager

In Linux, a package is like a box of toys. Imagine you want to play a game on your computer, but you don't have all the pieces. The package is like a box that contains all the pieces you need to play the game. Packages can contain all kinds of things, like programs, files, and settings.

A package manager is like a librarian who helps you find and check out the right box of toys. The package manager keeps track of all the boxes of toys, called packages, that are available for your computer. It helps you search for the right package and install it on your computer.

When you use a package manager, you can tell it what you want to do, like "install a new game" or "update an old program". The package manager will take care of finding the right package and installing it on your computer. It can also help you remove packages you don't need anymore.

Packages and package managers are like a way to keep your computer organized and make it easy to install and use new software.

### Task 1: Installing docker and Jenkins using Package Manager.

**Docker** is a platform for developers and sysadmins to develop, deploy, and run applications with containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

* To install Docker we will use the following commands;
    

1. Update the package index on your Ubuntu system:
    

```plaintext
sudo apt update
```

1. Install the required packages to use Docker’s repository:
    

```plaintext
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```

1. Add Docker’s official GPG key to your system:
    

```plaintext
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```

1. Add the Docker repository to APT sources:
    

```plaintext
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```

1. Update the package index again:
    

```plaintext
sudo apt update
```

1. Install Docker Community Edition:
    

```plaintext
sudo apt install docker-ce docker-ce-cli containerd.io
```

1. Verify that Docker is installed correctly by running the hello-world image:
    

```plaintext
sudo docker run hello-world
```

* To install Docker **on CentOS**, we will use the following command;
    

1. Update your system's package index:
    

```plaintext
sudo yum update
```

1. Install the required packages to use Docker's repository:
    

```plaintext
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
```

1. Add Docker's official GPG key to your system:
    

```plaintext
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
```

1. Install the latest version of Docker Community Edition:
    

```plaintext
sudo yum install docker-ce docker-ce-cli containerd.io
```

1. Start the Docker service:
    

```plaintext
sudo systemctl start docker
```

1. Verify that Docker is installed correctly by running the hello-world image:
    

```plaintext
sudo docker run hello-world
```

`systemctl` is a command used in Linux operating systems to control the state of the systemd system and service manager. It allows you to start, stop, restart, enable or disable system services, and get information about their status.

`systemd` is a system and service manager that is used by many Linux distributions. It is responsible for managing the system's services, daemons, and other processes, and is designed to be backwards-compatible with the traditional SysV init system. Systemd provides advanced features such as on-demand starting of daemons, socket-based activation, and parallelized service startup, among others.

**Jenkins** is an open-source automation server that helps to automate parts of the software development process. It can be used to automate building, testing, and deploying software, and provides a wide range of plugins that can be used to integrate with other tools and systems.

* To install jenkins on ubuntu 20.04
    

1. Update the package index on your Ubuntu system:
    

```sql
sudo apt update
```

1. Install Java on your system, since Jenkins requires Java to run:
    

```bash
sudo apt install -y default-jdk
```

1. Add the Jenkins repository key to your system:
    

```plaintext
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
```

1. Add the Jenkins repository to your system:
    

```plaintext
curl -fsSL https://pkg.jenkins.io/debian-stable/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-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
```

1. Update the package index again:
    

```sql
sudo apt update
```

1. Install Jenkins on your system:
    

```plaintext
sudo apt-get install jenkins -y
```

1. Start the Jenkins service:
    

```sql
sudo systemctl start jenkins
```

1. (Optional) Enable the Jenkins service to start on boot:
    

```bash
sudo systemctl enable jenkins
```

* Checking the status of the Docker service
    

The command used to check the status of the docker

```bash
systemctl status docker
```

Output

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679847776850/0d81a889-825f-4a91-b86b-997cd6b8f251.png align="center")

### **Task 2: Stopping Jenkins service and providing screenshots**

* Before **Stopping Jenkins Service** Screenshot
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679848534019/1a50277f-ac29-4e64-8caf-c5fdf8a31bcd.png align="center")

* After **Stopping Jenkins Service** screenshot
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679848674539/454630fd-d59d-4865-ad99-4718c126675f.png align="center")

### Task 3: The commands `systemctl` vs `service`

`systemctl` and `service` are commands used in Linux to manage system services. However, `systemctl` is newer and more powerful and is used in modern Linux distributions that use the `systemd` system and service manager. `service`, on the other hand, is an older and simpler command that is used in Linux distributions that use the older System V init system.

* `systemctl status jenkins`
    
* `service jenkins status`
