Day #7 : 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 package manager, you must understand what a package is.

What is a package?

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

Task 1: Installing Docker

Docker is a containerization platform that allows you to package applications and their dependencies into isolated units known as containers. Here's how to get it up and running:

  1. Open your terminal and run the following commands:

    
     ubuntu@ip-172-31-8-95:~$ sudo apt update
     ubuntu@ip-172-31-8-95:~$ sudo apt install docker
    

  2. After the installation is complete, enable the Docker service:

     ubuntu@ip-172-31-8-95:~$ sudo systemctl enable docker
    
  3. Start the Docker service:

     ubuntu@ip-172-31-8-95:~$ sudo systemctl start docker
     ubuntu@ip-172-31-8-95:~$ service docker status
    

  4. Verify the installation by running:

     ubuntu@ip-172-31-8-95:~$ docker --version
    

Task 2 : Installing Jenkins:

Jenkins is an open-source automation server that simplifies building, testing, and deploying software. Let's get it installed.

  1. Install Java Development Kit (JDK) 11:

    
     ubuntu@ip-172-31-8-95:~$ sudo apt install openjdk-11-jdk
    

  2. Check version:

     ubuntu@ip-172-31-8-95:~$ java --version
    

  3. Add the LTS (Long Term Support - Release): Learn more here

     sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
       https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
     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
     sudo apt-get update
     sudo apt-get install jenkins
    
  4. Verify Jenkins version

     ubuntu@ip-172-31-8-95:~$ jenkins --version
    

  5. Start and enable the Jenkins service:

     sudo systemctl start jenkins
     sudo systemctl enable jenkins
    

  6. Retrieve the initial admin password:

     sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    

  7. Open your browser and navigate to publicIP:8080 to complete the setup using the provided password.

    1. NOTE : Jenkins RUN's on Port 8080

      Getting a loading screen check below no worries it is expected!

      we need to do few minor changes and here we go:

      1. Goto : Security -> Security Groups (Click on Link)
    2. Click on : Edit Inbound Rules

    3. Click on Add Rule

      Now add a new rule : add port 8080 as given below and allow the traffic from everywhere -> Tap on Save rules

      Now again hit the same publicIP:8080 : Congratulation you made it

    4. You will be prompted to unlock Jenkins. You can find the initial administrator password in the Jenkins server logs. You can use the following command to print it:

       ubuntu@ip-172-31-8-95:~$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
      
    5. Follow the on-screen instructions to complete the Jenkins setup.

    6. Now, Jenkins should be successfully installed on your Ubuntu system, and you can use it for continuous integration and automation tasks.

  8. Now we will create the admin user

  9. Welcome to the jenkins deahboard

  10. to stop jenkins and check the status execute the below commands

ubuntu@ip-172-31-8-95:~$ sudo systemctl stop jenkins
ubuntu@ip-172-31-8-95:~$ sudo systemctl status jenkins

Managing Services with systemctl and systemd:

systemctl is a powerful command used to examine and control the state of the systemd system and service manager, which is commonly used in most Unix-like operating systems. With systemctl, you can start, stop, enable, or disable services and check their status. This is particularly useful when working with tools like Docker and Jenkins.

Conclusion

In a nutshell, Day 7 of #90DaysOfDevOps introduced us to the vital role of package managers in Linux, helping us install and manage software packages efficiently. We explored different types of package managers tailored to various packaging systems.

We also dived into systemctl and systemd, understanding their significance in system and service management. The day's tasks involved installing Docker and Jenkins using package managers, along with learning how to use systemctl for service control.

Join us in this exciting DevOps journey, and stay tuned for more insights and hands-on experience in the days to come. #DevOps #Linux #PackageManagement