๐ป๐๐ช ๐: "๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐ฆ๐ฉ โ๐๐๐๐๐๐ ๐๐๐๐๐๐๐๐๐๐ฅ ๐๐๐ ๐๐ช๐ค๐ฅ๐๐๐๐ฅ๐: ๐ธ โ๐ ๐๐ก๐ฃ๐๐๐๐๐ค๐๐ง๐ ๐พ๐ฆ๐๐๐"
Table of contents
- ๐ฒ๐ฝ๐ถ๐ ๐พ๐ ๐ซ๐ถ๐ธ๐๐ถ๐๐ ๐๐ถ๐๐ถ๐๐๐๐๐๐?
- ๐๐ฒ๐ฏ๐ฏ๐ฎ๐ป๐ฎ๐ท๐ฝ ๐ฃ๐๐น๐ฎ๐ผ ๐ธ๐ฏ ๐๐ช๐ฌ๐ด๐ช๐ฐ๐ฎ ๐๐ช๐ท๐ช๐ฐ๐ฎ๐ถ๐ฎ๐ท๐ฝ ๐ฃ๐ธ๐ธ๐ต๐ผ
- ๐๐ฒ๐ฏ๐ฏ๐ฎ๐ป๐ฎ๐ท๐ฌ๐ฎ ๐ซ๐ฎ๐ฝ๐๐ฎ๐ฎ๐ท ๐จ๐ค๐ ๐ค๐๐๐๐ฃ๐ & ๐จ๐ค๐ ๐ค๐๐๐ก๐๐๐?
- How to check all the options of the YUM?
- How to check history using YUM
- Undo/Redo with YUM
- Tips
- RPM Package Manager
- Limitation of RPM
- How to use RPM
- Another way to install with RPM and show the progress bar
- How to delete a file using RPM
- Few more RPM commands
- DNF Package Manager
- Some dnf commands:
- APT Package Manager
- Some APT Commands:
- Practical Tasks:
๐ฒ๐ฝ๐ถ๐ ๐พ๐ ๐ซ๐ถ๐ธ๐๐ถ๐๐ ๐๐ถ๐๐ถ๐๐๐๐๐๐?
Package management in Linux refers to the process of installing, updating, configuring, and removing software packages on a Linux-based operating system. It's a fundamental component of maintaining a Linux system and ensuring that the software installed on it is up-to-date, secure, and well-integrated.
Everything related to the management of those packages is called Package Management
๐๐ฒ๐ฏ๐ฏ๐ฎ๐ป๐ฎ๐ท๐ฝ ๐ฃ๐๐น๐ฎ๐ผ ๐ธ๐ฏ ๐๐ช๐ฌ๐ด๐ช๐ฐ๐ฎ ๐๐ช๐ท๐ช๐ฐ๐ฎ๐ถ๐ฎ๐ท๐ฝ ๐ฃ๐ธ๐ธ๐ต๐ผ
Different Linux system comes with different package management tools such as YUM/DNF, RPM, APT, Flatpak, Snap etc
But, Today we will learn about YUM/DNF, RPM and APT Package Managers
๐จ๐ค๐/๐๐๐ ๐๐ช๐ฌ๐ด๐ช๐ฐ๐ฎ ๐๐ช๐ท๐ช๐ฐ๐ฎ๐ป
Yum (Yellowdog Updater, Modified) is a package manager used in Red Hat-based Linux distributions like Red Hat Enterprise Linux (RHEL), CentOS, and Fedora. It simplifies the installation, updating, and removal of software packages. Yum automatically handles dependencies and connects to software repositories to fetch and manage packages. It's a command-line tool that makes software management more efficient in these Linux distributions.
YUM is a primary package Management Tool for Redhat
YUM performs dependency resolution when installing, updating and removing software packages
YUM can manage packages from installed repositories in the system or from .rpm packages.
๐๐ธ๐ ๐ฝ๐ธ ๐พ๐ผ๐ฎ ๐จ๐ค๐ ๐ฒ๐ท ๐๐ฒ๐ท๐พ๐?
We will look at some of the commands with the YUM package manager. commands such as install, remove, upgrade etc.
- How to install a package using YUM
yum install nginx -y
How to remove the package using YUM
yum remove nginx
How to update a package using YUM
yum update nginx
Since we have installed nginx just now, it is a fresh update therefore we cannot see any updates there, but if you're version of nginx is old then you can easily update it with the update command.
How to upgrade a package using YUM
yum upgrade nginx
The same goes for the upgrade part. It is the latest version we have just now installed therefore there are now current upgrades available.
๐๐ฒ๐ฏ๐ฏ๐ฎ๐ป๐ฎ๐ท๐ฌ๐ฎ ๐ซ๐ฎ๐ฝ๐๐ฎ๐ฎ๐ท ๐จ๐ค๐ ๐ค๐๐๐๐ฃ๐ & ๐จ๐ค๐ ๐ค๐๐๐ก๐๐๐?
Update: It will keep the old packages, so we can roll back to the previous one if the new one has issues.
Upgrade: It will delete the old packages and will install the latest version.
How to check all the options of the YUM?
yum -options
There are many more commands available further below.
The packages listed above can be updated to the latest version using the update command.
How to check history using YUM
yum check-update
We use the history
command to check all the past work that has been done related to the packages history
command will show you the activity with the date and time.
Undo/Redo with YUM
yum history undo/redo <id>
here, undo
is also works for rollback
to the previous update
This will undo the process of installing Nginx
Tips
if you're using you're system as a normal user then you will have to use sudo commands before the yum commands.
If you're using it as a root user then you can directly use the commands without using the sudo command.
RPM Package Manager
The RPM Package Manager, often referred to as RPM, is a package management system for Linux-based operating systems. It is primarily used in Red Hat, CentOS, Fedora, and other related distributions. RPM is responsible for:
Packaging: It creates software packages in the RPM format, which contain the software, metadata, and installation scripts.
Installation: RPM installs software packages on your system, managing dependencies to ensure that all required components are in place.
Querying: It allows users to query the system for installed packages, verifying package information and version details.
Updates: RPM can update software packages by replacing older versions with newer ones.
Removal: It removes packages from the system cleanly, making sure to address any dependencies affected by the removal.
RPM Package Manager is also called RedHat package manager.
using RPM you can install, uninstall and query individual software packages.
RPM maintains a database of installed packages that enable powerful and fast queries.
Limitation of RPM
- RPM cannot manage dependencies like the YUM package manager.
How to use RPM
- How to install a package using RPM
rpm -i package-name
- -i is used to install a package
To install an RPM file first you have to download a .rpm file from the web which you can easily do with the wget magic trick๐ช
Once you see that the file is downloaded then you can use the rpm commands to install the .rpm file
You can now see that the file is installed without any issue with the rpm package manager.
- How to upgrade a package in RPM
rpm -U package-name
- here, capital -U is used to upgrade an RPM package manager
You can see that the package we have installed is the most up-to-date package and that's why it has no pending upgrades.
Another way to install with RPM and show the progress bar
rpm -ivh package-name
-i stands for install
-v stands for verbose
-h is used to show the hash rate (progress bar)
How to delete a file using RPM
rpm -evh package-name
-e stands for erase (remove/uninstall)
-v stands for verbose
-h stands for the hash rate (progress bar)
Few more RPM commands
- To query all the installed packages
rpm -qa
- To get more info about the package using RPM
rpm -qi package-name
- How to get info about a config file for a package
rpm -qc package-name
DNF Package Manager
DNF (Dandified YUM) is a modern package manager primarily used in Red Hat-based Linux distributions like Fedora and CentOS. It serves as a command-line tool for installing, updating, and managing software packages on these systems. dnf
is an improved and more user-friendly replacement for the older Yum
package manager.
Some dnf commands:
- How to list all the available packages in dnf
sudo dnf list available
- How to list all the installed packages in dnf
sudo dnf list installed
- How to update a package using dnf
sudo dnf update
- How to upgrade a package using dnf
sudo dnf upgrade
- How to install a package using dnf
sudo dnf install package-name
- How to remove a package using dnf
sudo dnf remove package-name
- How to get info about a package
sudo dnf info package-name
- How to search a package using dnf
sudo dnf search package
Moving ahead, let's see about the APT package manager.
APT Package Manager
APT (Advanced Package Tool) is a package management system used in Debian-based Linux distributions, such as Debian and Ubuntu. It simplifies the installation, updating, and removal of software packages. APT manages a vast repository of pre-compiled software packages, making it easy for users to access and maintain their systems with a few simple commands. It handles dependencies, ensuring that all required components for a particular software package are installed. APT is known for its reliability, and it is often used through commands like apt-get
and apt
.
APT is also known as the Advance Packaging Tool.
APT is very similar to YUM commands.
APT is generally used for Debian systems like Ubuntu, Kali Linux etc.
Some APT Commands:
- How to install a package using apt
apt install package-name
apt-get install package-name
Since I'm using Ubuntu as my main system and Ubuntu is Debian-based system that is why it uses apt package manager and it's amazing. To see what I have installed see below.
Isn't this cool ๐ you can do many more things like this with the apt package manager.
- How to remove a package using apt
apt remove package-name
- How to remove dependencies of a removed package
apt autoremove
- How to update the repository
apt update
- How to search for an app in the cache
apt-cache search package-name
Practical Tasks:
How to install Docker on the system using the package manager?
What is Docker?
Docker is a platform for developing, shipping and running applications in containers. Containers are lightweight, isolated environments that package an application and its dependencies, making it easy to deploy and run the same software consistently across different environments. Docker simplifies software development, testing, and deployment by providing a standardized way to package and manage applications.
To perform this task we will use the apt package manager. Since I'm using Ubuntu 23.10. The APT package manager is my default package manager.
- Set up Docker's
apt
repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
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.gpg
# Add the repository to Apt sources:
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
sudo apt-get update
To install docker on your system you can use the following commands. These are not just some random commands but are from Docker's official website.
- Install the Docker packages.
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
If you see this output, then you have successfully installed and started the Docker engine.
How to install Jenkins on the system using the package manager?
Jenkins is like a digital assistant for software developers. It helps them build and release their software more easily. Think of it as a robot that can automatically do repetitive tasks, like testing the code and sending it to the server when it's ready. This saves time and makes sure everything works smoothly in the software development process.
To install Jenkins on our system will do:
- Check if you already have JAVA installed on your system
- Start by importing the GPG key. The GPG key verifies package integrity but there is no output
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
- Add the Jenkins software repository to the source list and provide the authentication key:
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
-
Update Your System
sudo apt-get update
- Install Jenkins
sudo apt-get install jenkins
As you can see above, Jenkins has been successfully installed on our system.
What is Systemctl?
Systemctl is a command in Linux used to manage system services. It allows you to start, stop, restart, enable, disable, and check the status of services, making it a crucial tool for controlling and monitoring system processes and daemons.
What is Systemd?
Systemd is a system and service manager in Linux that handles the startup, management, and control of system processes and services. It's a replacement for the traditional System V init system and provides features like parallel startup, service dependencies, logging, and more.
Some commands of Systemctl:
systemctl start service-name
: Start a specific service.systemctl stop service-name
: Stop a specific service.systemctl restart service-name
: Restart a specific service.systemctl status service-name
: Check the status of a service.systemctl enable service-name
: Enable a service to start at boot.systemctl disable service-name
: Disable a service from starting at boot.systemctl list-units --type=service
: List all active services.systemctl list-unit-files --type=service
: List all available services.
Note: To enable all these services you need to have admin rights.
Systemctl Tasks:
- check the status of the Docker Service in your system
systemctl status docker
- stop the service, Jenkins
you can see that the jenkins service is active on our system and now let's stop the Jenkins service
systemctl stop jenkins
systemctl status jenkins
Congratulations ๐ you have now understood the concepts of package manager and systemctl commands in Linux. You have also learned how to start and stop a service and also how to check the status of that service.
Summary
Explains package management in Linux, specifically focusing on YUM/DNF, RPM, APT, and DNF package managers. It covers the basics of each package manager, including installation, removal, updates, and other common commands. The text also briefly introduces Docker and Jenkins installation processes and provides practical examples of using systemctl to manage system services.
In summary, package management is essential for installing, updating, and removing software packages in Linux. Various package managers like YUM/DNF, RPM, APT, and DNF are available, each with its own set of commands and functionalities. The text also introduces systemctl as a tool for managing system services.