#Day7 #90DaysofDevOps 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.
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 packaging system but 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.
How to install Docker
Remove docker if already installed
sudo apt-get remove docker docker-engine
docker.io
Update package list
sudo apt-get update
- Install Docker package
sudo apt install
docker.io
- Install dependency packages
sudo snap install docker
- Check version of docker
docker -- version
- Pull an image from docker hub using following command
sudo docker run hello-world
- Check if docker image has been pulled and is present in the system
sudo docker images
- To display all the containers pulled, use following
sudo docker ps -a
- To check containers in running state, use following
sudo docker ps
How to install Jenkins
Install Java
sudo apt-cache search openjdk
sudo apt-get install openjdk-11-jre -y
Check Java version
java --version
- Update package list
sudo apt update
- Add the repository key to the system:
wget -q -O -
https://pkg.jenkins.io/debian-stable/jenkins.io.key
| sudo apt-key add -
- Next, let’s append the Debian package repository address to the server’s
sources.list
:
sudo sh -c 'echo deb
http://pkg.jenkins.io/debian-stable
binary/ > /etc/apt/sources.list.d/jenkins.list'
- After both commands have been entered, we’ll run
update
so thatapt
will use the new repository
sudo apt update
- Finally, we’ll install Jenkins and its dependencies.
sudo apt install jenkins
- Starting jenkins
sudo systemctl start jenkins
- Since
systemctl
doesn’t display status output, we’ll use thestatus
command to verify that Jenkins started successfully:
sudo systemctl status jenkins
- Opening the Firewall port 8080
sudo ufw allow 8080
- Check status
sudo ufw status
- If status is inactive
sudo ufw allow OpenSSH
sudo ufw enable
- Check status again
sudo ufw status
- Setting up Jenkins
To set up your installation, visit Jenkins on its default port, 8080
, using your server domain name or IP address: http://your_server_ip_or_domain:8080
- Here It will ask for a password to log in as path of the password is highlighted in red colour just copy it and paste into your browser:
systemctl and system:
Systemd is a system and service manager, while systemctl is a command-line utility for managing system services.
Systemd provides a suite of daemons, libraries, and utilities to manage system components, while systemctl is a specific tool within that suite.
check the status of the docker service in your system:
Check the status of the Docker service on your Linux system using the following command in the terminal:
sudo systemctl status docker
To Stop the Service:
To stop the Docker service, you can use the following command in the terminal:
sudo systemctl stop docker
This will stop the Docker service immediately. If you want to prevent the service from starting automatically at boot, you can also disable it using the following command:
sudo systemctl disable docker
check the status of Jenkins service in your system:
sudo systemctl status jenkins
To Stop the Service:
To stop the Jenkins service, you can use the following command in the terminal:
sudo systemctl stop jenkins
systemctl
The systemctl command manages both system and service configurations, enabling administrators to manage the OS and control the status of services. Further, systemctl is useful for troubleshooting and basic performance tuning.
service
The service command starts, stop and restart a daemon or services by calling the script. Usually all scripts are stored in /etc/init. d directory. It runs a script in as predictable environment as possible.
systemctl vs service
systemctl is basically a more powerful version of service. With service you can only do commands related to the service (i.e. status, reload, restart) whereas with systemctl you can use more advanced commands such as: systemctl is-failed name.service # check if service failed to load