# Day 7 - 90DaysofDevOps

## Understanding package manager and systemctl

### Package Manager

It is a tool in the operating system that allows the user to install, upgrade or remove software packages. These go by different names for different OS. In Linux it is Yum, in Ubuntu(Debian) it is apt-get, etc.

**What is a Package?**

It is an application that can be a command line tool, a GUI application or a software library that may be required by other applications. A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.

Let's dive into some examples of installing a package.

**Installing Docker**

In Ubuntu for installing Docker

Follow command:-

sudo apt-get update

sudo apt-get install docker.io -y

sudo usermod -aG docker $USER

sudo reboot

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686054999621/cd016639-2b5e-4716-88bb-38d36b204a86.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055075665/a8b84367-6e6e-4ab3-981d-d061832ae904.png align="center")

### Installing Jenkins

For installing Jenkins we need to install Java first :

Steps to install Java

```plaintext
sudo apt update
sudo apt install openjdk-11-jre
java -version
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055262543/b0c452a9-8e2d-4150-bb63-cd5b820d2cda.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055292762/752f1c49-b34e-443f-b6be-938bef9bb144.png align="center")

After installing Java we can install Jenkins

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055531178/40c44d3c-ba46-49d0-9c07-d89253e48964.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055598152/e225866c-2341-4e7e-b189-0d789d9be2f2.png align="center")

### **Systemctl**

Systemctl is used to detect the state of an installed package whether it is in running, stopped, enabled or disabled state. It is used to change the state of any packages according to the user's needs.

**systemctl start &lt;package&gt;**

It is used to start the service of any application package.

**systemctl stop &lt;package&gt;**

It is used to stop the service of any installed package.

**systemctl status &lt;package&gt;**

It is used to check the current state of the application package.

**systemctl enable &lt;package&gt;**

It ensures the condition of application services remains the same even after the instance(VM) restarts.

Let's check the systemctl for the installed application i.e. Docker and Jenkins.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055740318/25e0f998-1127-4dfb-a8d4-e2a32b3497e7.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055775440/a2d58668-d263-4337-a6aa-7376d4f15f08.png align="center")
