Day 7 Task: 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 centre or a command line tool like apt-get
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.
systemctl and systemd
systemctl is used to examine and control the state of “systemd” system and service manager. systemd is system and service manager for Unix like operating systems(most of the distributions, not all).
Tasks
You have to install docker and jenkins in your system from your terminal using package managers
Write a small blog or article to install these tools using package managers on CentOS
Read about the commands systemctl vs service
Installing Docker on CentOS
Install using the rpm repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
Set up the repository
Install the yum-utils package (which provides the yum-config-manager utility) and set up the repository.
sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoInstall Docker Engine
Install Docker Engine, containerd, and Docker Compose:To install the latest version, run:
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginStart Docker
sudo systemctl start dockercheck the status of docker engine by using this command
sudo systemctl status docker
Jenkins Installation on CentOS
Jenkins is an open-source, Java-based automation server that offers an easy way to set up a continuous integration and continuous delivery (CI/CD) pipeline.
Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. Continuous delivery (CD) is a series of practices where code changes are automatically built, tested and deployed to production.
Install Java:Jenkins requires Java to run. You can install OpenJDK, which is a free and open-source implementation of the Java Platform.
Install it using the following command:
sudo yum install java-11-openjdk-devel
Install Wget:
Next, install the “wget” package to use “wget” utility to download files from website
sudo yum install -y wget
Add Jenkins Repository: Next, add the Jenkins repository to your system by creating a Jenkins YUM repository file:
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Import Jenkins GPG Key:Import the Jenkins GPG key to verify the integrity of the Jenkins packages:
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
Install Jenkins: Now, install Jenkins using the following command:
sudo yum install jenkins -y
Start Jenkins: Start the Jenkins service and enable it to start on boot:
Sudo systemctl start jenkins
Open a Web Browser and Access Jenkins: Jenkins should now be running. You can access it through your web browser by navigating to http://your_server_ip:8080. To retrieve the initial Jenkins administrator password, run:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Configure Jenkins: After the initial setup, you can configure Jenkins to meet your specific needs. This includes installing additional plugins, configuring security settings, and creating build jobs.
Create Jenkins admin user:Next, create jenkins admin user and password details as mentioned in below screenshot to login with Jenkins admin account
Now your jenkins has been ready to use and configure as per your requirements
systemctl vs service
Both systemctl and service are used to manage services in Linux. systemctl is a newer command that was introduced with Systemd. You should prefer systemctl over service as it provides more advanced features.
What is a service?
A service is a program that runs in the background and performs a specific task. For example, the httpd service runs the Apache HTTP server, the mysqld service runs the MySQL database server, and the sshd service runs the OpenSSH server. To start, stop, or restart a service, you can use the systemctl or service command.
What is service command?
service is a legacy command that has been used in earlier versions of Linux to manage services. It is still available in many Linux distributions and can be used to start, stop, and restart services. For example, you might have used the following command to start, stop or restart the httpd service:
systemctl start httpd systemctl stop httpd systemctl restart httpd
Which command should I use?
You should prefer systemctl over service as it provides more advanced features and is the relatively newer command. However, service is still available in many Linux distributions and can be used to start, stop, and restart services.



