Understanding package manager and systemctl

Understanding package manager and systemctl

What is a package manager in Linux?

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.

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.

What are the 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: Install docker and Jenkins in your system from your terminal using package managers:

Installing Docker:

Docker is an open platform for developing, shipping and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

To install docker, I will use the AWS EC2 Ubuntu machine. With the help of official docker documentation, we can easily follow the installation procedure here:

Steps:

Update the?apt?package index and install packages to allow?apt?to use a repository over HTTPS:

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg        

Add Docker’s official GPG key:

sudo install -m 0755 -d /etc/apt/keyring
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpgs        

Use the following command to set up the repository:

echo 
?"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
?"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
?sudo tee /etc/apt/sources.list.d/docker.list > /dev/null\        

Update the?apt?package index:

sudo apt-get update        

To install the latest version, run:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin        

Verify that the Docker Engine installation is successful by running the?hello-world?image:

sudo docker run hello-world        

This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

Here is the output of the same on the ec2 instance which I created for testing purposes:

No alt text provided for this image
ec2 instance capture

For installing docker on CentOS, please follow this documentation


Installing Jenkins:

Jenkins is an open-source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat.

To install Jenkins, I will use the AWS EC2 Ubuntu machine. With the help of official Jenkins documentation, we can easily follow the installation procedure here:

Steps:

Add the repository key to your system:

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

Updating the repository:

sudo apt-get update        

Installing Jenkins:

sudo apt-get install jenkins        

Enabling the Jenkins service to start at boot with the command:

sudo systemctl enable jenkins        

Starting the Jenkins service with the command:

sudo systemctl start jenkins        

Checking the status of the Jenkins service using the command:

sudo systemctl status jenkins        

If everything has been set up correctly, you should see an output like this:

No alt text provided for this image
jenkins status

Browsing to https://<server_ip>:8080?(or whichever port you configured for Jenkins when installing it) and wait until the?Unlock Jenkins?page appears.

No alt text provided for this image

From the Jenkins console log output, copy the automatically-generated alphanumeric password (between the 2 sets of asterisks). The command will print the password at the console:?

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

On the?Unlock Jenkins?page, paste the password into the?Administrator password?field and click?Continue. Once this is done, post-installation tasks can be done.


systemctl and systemd:

systemd is a system and service manager for modern Linux systems that provides a standard process for controlling system startup and managing system services. systemd is designed to replace the traditional SysV init system, which manages the boot process and runs system services in a sequential manner.

systemctl is a command-line utility that is used to control and manage systemd. It allows you to start, stop, restart, enable, disable, and check the status of system services. systemctl also provides logging and debugging tools to help troubleshoot issues with system services.

Systemd and systemctl work together to provide more efficient and flexible system management for Linux. systemd is designed to improve system boot and shutdown times, provide better resource management, and offer more detailed logging and debugging capabilities. systemctl makes it easy to control and manage system services, simplifying the process of system administration.

Tasks:

  1. Check the status of docker service in your system:

using the following command;

sudo service docker status        

the status would look this this:

No alt text provided for this image
docker service status

2. stop the service Jenkins and post before and after screenshots:

Before:

No alt text provided for this image

After stopping the service:

Using the command "sudo service jenkins stop", the status of the Jenkins service would look like this:

No alt text provided for this image
Stopped Jenkins service

Difference between "systemctl status docker" & "service docker status"

Both systemctl status docker and service docker status commands are used to check the status of the Docker daemon on a Linux system. However, they differ in the way they interact with the system's init system.

systemctl is the default init system manager in most modern Linux distributions that use systemd. It is a command-line utility that provides a system and service manager for Linux systems. The systemctl status command is used to display the status of a particular service in the systemd unit hierarchy.

On the other hand, service is an older init system manager that is still used on some Linux distributions. The service command is used to control the system services and their status. It is used to manage the services in the /etc/init.d directory.

In summary, the main difference between systemctl status docker and service docker status is the underlying init system manager they use. If your Linux distribution uses systemd, then you should use systemctl to interact with the system services. If your distribution uses the older init system manager, you should use service to interact with the system services.



#90daysofdevops #devops #linux

要查看或添加评论,请登录

Shubham Deshpande的更多文章

  • Docker Important Interview Questions

    Docker Important Interview Questions

    Docker is a good topic to ask in DevOps Engineer Interviews, mostly for freshers. One must surely try these questions…

  • Docker- Volumes and Networking

    Docker- Volumes and Networking

    Docker-Volume Docker volumes are a mechanism for persistently storing data generated or used by Docker containers. They…

  • Docker-compose

    Docker-compose

    ||Docker Compose|| Docker Compose is a tool that allows us to define and manage multi-container Docker applications. It…

  • Docker Project for DevOps Engineers

    Docker Project for DevOps Engineers

    Dockerfile: A Dockerfile is a text file that contains a set of instructions to build a Docker image. It provides a…

  • Docker for DevOps Engineers

    Docker for DevOps Engineers

    Docker is an open-source platform that allows you to automate the deployment, scaling, and management of applications…

  • Python Libraries for DevOps

    Python Libraries for DevOps

    ||Python Libraries for DevOps|| Parsing files in Python refers to the process of reading and interpreting the contents…

    2 条评论
  • Python Data Types and Data Structures for DevOps

    Python Data Types and Data Structures for DevOps

    ||Python Data Types and Data Structures for DevOps|| Data Types: Data types in Python define the type and behavior of…

    1 条评论
  • Starting with Python

    Starting with Python

    Introduction: Python is a Open source, general purpose, high level, and object-oriented programming language. It was…

  • Advance Git & GitHub for DevOps Engineers: Part-2

    Advance Git & GitHub for DevOps Engineers: Part-2

    ||Advance Git & GitHub for DevOps Engineers: Part-2|| Git Stash: Git stash is a command that allows you to temporarily…

  • Advanced Git & GitHub for DevOps Engineers

    Advanced Git & GitHub for DevOps Engineers

    Git Branching: Git branching is a fundamental feature of the Git version control system that allows for parallel…

社区洞察

其他会员也浏览了