Understanding package manager and systemctl
Day 7 : #90DaysOfDevOps Challange
Table of contents
No headings in the article.
A package manager is a software tool that automates the process of installing, upgrading, configuring, and removing software packages. It typically uses a centralized repository of packages to download and install software and its dependencies. Package managers help users manage software installations and updates, ensure that software is installed with the correct dependencies and configuration, and simplify the process of software installation.
Some popular package managers include:
APT (Advanced Package Tool) for Debian-based Linux distributions like Ubuntu.
YUM (Yellowdog Updater Modified) and DNF (Dandified YUM) for Red Hat-based Linux distributions like CentOS and Fedora.
Homebrew for macOS.
Task 1. You have to install docker and jenkins in your system from your terminal using package managers
Install Docker:
For Ubuntu or Debian-based systems:
Update the package list:
sudo apt update
Install packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable repository:
echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update the package list with the Docker packages from the newly added repository:
sudo apt update
Finally, install Docker:
sudo apt install docker-ce docker-ce-cli containerd.io
For CentOS or RHEL-based systems:
Install the required packages:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Use the following command to set up the stable repository:
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
Install Docker:
sudo yum install docker-ce docker-ce-cli containerd.io
Install Jenkins:
For Ubuntu or Debian-based systems:
Add the Jenkins repository key to the system:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Add the Jenkins repository to the system:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Update the package list:
sudo apt update
Finally, install Jenkins:
sudo apt install jenkins
For CentOS or RHEL-based systems:
Add the Jenkins repository to the system:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
Import the Jenkins repository key:
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Install Jenkins:
sudo yum install jenkins
Task 2. check the status of docker service in your system (make sure you completed above tasks, else docker won't be installed) To check the status of the Docker service on your system, you can use the following command:
sudo systemctl status docker
This will display the current status of the Docker service, including whether it is running or not, any errors or warnings, and other relevant information. If the service is running, you should see a message similar to the following:
If the service is not running, you can start it using the following command:
sudo systemctl start docker
And then check its status again using the above command.
Task 3. Stop the service jenkins and post before and after screenshots
Cheack the status of jenkins
To stop the Jenkins service, use the following command:
sudo systemctl stop jenkins
After this command :
Task 3. read about the commands systemctl vs service.
systemctl
and service
are two different commands used in Linux to manage system services.
systemctl
is a newer command introduced with systemd, a system and service manager for Linux. It is used to control and manage the systemd system and service manager. systemctl
allows you to start, stop, restart, enable, and disable services, and also to view the status of services.
The service
command, on the other hand, is an older command that is still used on some Linux systems. It is used to start, stop, and restart services, and also to view the status of services. However, unlike systemctl
, service
does not allow you to enable or disable services.
While both commands can be used to manage services, systemctl
is generally considered to be the preferred command because it is more powerful and flexible, and allows you to do more than the service
command. It also has more features and options, and is more standardized across different Linux distributions.
So, in summary, systemctl
is a newer and more powerful command used to manage systemd services, while service
is an older and simpler command used to manage system services on some Linux systems.