Introduction:
Today's adventure leads us into the realm of Linux package management. In this digital expanse, where every byte matters, two mighty companions emerge: Package Managers and Systemctl. Let's embark on a journey to unravel their mysteries and master their powers! ๐
What is a package?
A package is a compressed collection of files that make up a software application or component. These files include executables, configuration files, libraries, and documentation. Packaging software ensures that it can be efficiently distributed and installed on various systems.
What is a package manager in Linux?
Package managers are tools that automate the process of installing, updating, and removing software packages on a system. They handle dependencies (other software components required by the package), ensuring that everything needed for a program to run smoothly is in place.
Different kinds of package managers:
There are several package managers available:
APT (Advanced Package Tool): Used by Debian and Ubuntu, APT employs a system of repositories to manage packages and their dependencies.
Yum and DNF: These are used by Red Hat-based distributions like Fedora and CentOS. DNF is an improved version of Yum, focusing on performance and better dependency resolution.
Pacman: This package manager is used by Arch Linux and its derivatives. It boasts a simple design and aims for a minimalistic approach.
Tasks:
Installing docker package on Ubuntu
First, update and then upgrade the installed packages-
ubuntu@~$: sudo apt update -y
ubuntu@~$: sudo apt upgrade -y
Installing docker package-
ubuntu@~$: sudo apt install docker.io -y
Check the version of docker-
ubuntu@~$: docker -v
Install jenkins in your system from your terminal using package managers
Jenkins is a widely used automation server. Jenkins requires Java to run.
So first we update the system and then install openjdk-17-jre
package-
ubuntu@~$: sudo apt update
ubuntu@~$: sudo apt install openjdk-17-jre
Next, import the GPG key & Add the Jenkins software repository to the source list and provide the authentication key-
curl -fsSL https://pkg.jenkins.io/debian/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 binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
Update the system and then install Jenkins-
sudo apt-get update
sudo apt-get install jenkins
Set Jenkins to listen on port 8080. Go to the security groups of the server and add an inbound rule for port 8080. Now, Access this port with your browser to start configuration.
systemd and systemctl
systemd : Imagine your computer is like a team of workers, each with their own job to do. Systemd is like the boss who makes sure everyone starts working when the computer turns on and keeps an eye on them to make sure they're doing their tasks correctly. It also helps the computer do things like connect to the internet and handle other important jobs. So, systemd is like the manager that helps your computer run smoothly and get things done.
systemctl : systemctl is used to detect the state of an installed package whether it is in a running, stopped, enabled or disabled state. It is used to change the state of any package according to the user's needs.
Some of the common systemctl commands:
#start service
systemctl start <service_name>
#stop service
systemctl stop <service_name>
#restart service
systemctl restart <service_name>
#check the status of the service
systemctl status <service_name>
#To add the service to startup process list & this service will start when the system starts.
systemctl enable <service_name>
#To remove the service from startup process list.
systemctl disable <service_name>
Check the status of docker service
To check the status of the Docker service:
systemctl status docker
Stop and start Jenkins service
To start the Jenkins service:
systemctl start jenkins
To stop the Jenkins service:
systemctl stop jenkins
Conclusion
In the realm of modern software management, package managers and systemctl/systemd are invaluable tools. Package managers streamline the process of installing, updating, and removing software packages, ensuring smooth interactions between components. Meanwhile, systemctl and systemd provide efficient management of services, allowing us to control their behavior seamlessly.
By mastering these tools, you're equipped with the knowledge to take charge of your system's software environment effectively. So go ahead, and explore the world of packages and services with confidence! โ