Day 7: Linux Package Manager And Systemctl

Day 7: Linux Package Manager And Systemctl

What is a package manager in Linux?

In Linux, a package manager is a tool that is used to manage the installation, removal, and updating of software packages. A software package is a collection of files that are compiled and packaged together for easy distribution and installation.

The package manager maintains a database of available software packages, along with information about their dependencies (other packages they require to function properly) and the version numbers of the packages installed on the system. This information is used to resolve dependencies and ensure that the correct version of a package is installed.

Package managers also provide a way to search for and install new packages and remove or upgrade existing ones. They typically include features such as automatic dependency resolution, dependency tracking, and conflict resolution.

Some popular package managers in Linux include:

  • Debian/Ubuntu: apt, aptitude

  • Red Hat/Fedora/CentOS: yum, dnf

  • Arch Linux: Pacman

  • Gentoo Linux: Portage

Package managers make it easy to manage software installations and updates, making Linux a flexible and customizable operating system.

Task 1: Installing Docker on Ubuntu:

Command: Sudo apt-get install docker.io

  1. The above command will install the docker package and its dependencies in your system.

  1. Check the status of the docker service using the below command:
    "Sudo systemctl status docker"

  2. Check the version of the docker using:

    docker --version

Task 2: Installing Jenkins

  1. The pre-requisite to install Jenkins is Java. We will check if Java is installed in our system or not.

    Java is not found in the system. Therefore, we will install it using OpenJDK:
    command : sudo apt install openjdk-11-jdk -y

  2. Check the version again after installing Java:

  3. Add Jenkins repository:
    1. Start by importing the GPG key. The GPG key verifies package integrity but there is no output. Run:
    "curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null"

    2. Add the Jenkins software repository to the source list and provide the authentication key:
    "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"

    3. After this update your local package index:
    "Sudo apt-get update"

    4. Then install Jenkins by using the below command:
    "sudo apt-get install Jenkins"

    5. Check the status of Jenkins:

    6. Open port 8080 by editing inbound rules for your ec2 instance or your Linux machine:

    7. Open a web browser and navigate to your server's IP address. Use the following syntax:

    8. No you cat look the password at the given location using the below command:

    9. cat /var/lib/jenkins/secrets/initialAdminPassword

    10. After that you can login and create your username and password

    What is Systemctl in Linux?

    systemctl is a command-line utility that is used to control the state of the systemd system and service manager in Linux operating systems. Systemd is a software suite that provides system and service management capabilities for Linux operating systems and is the default system and service manager for many modern Linux distributions.

    1. The systemctl command allows system administrators to manage and control the behavior of system services, such as starting, stopping, restarting, enabling, disabling, and querying the status of services. It also provides a way to manage the boot process, including controlling the default target or run level, setting the default boot target, and displaying the current boot status.

      Some common systemctl commands include:

      • systemctl start [service]: starts a service

      • systemctl stop [service]: stops a service

      • systemctl restart [service]: restarts a service

      • systemctl enable [service]: enables a service to start automatically at boot time

      • systemctl disable [service]: disables a service from starting automatically at boot time

      • systemctl status [service]: displays the status of a service

The system command is a powerful tool for system administrators and can help manage and troubleshoot system services in Linux.