๐ฆ What is a Package?
A package is a bundle of files and metadata. It is usually referred to as an application but it could be a GUI application, command line tool, or a software library (required by other software programs).Think of it as a neatly wrapped gift containing everything needed for a software application to run.
This can include:
Executable files: The main program that runs.
Libraries: Shared code that helps the program to function.
Documentation: Guides and manuals for using the software.
Configuration files: Settings that help the software run correctly.
๐ฆ Examples of Packages:
Application Software: Like a web browser or a game.
System Software: Like utilities for managing files or settings.
๐ฆ What is a Package Manager in Linux?
A Package Manager is like a superhero librarian for your computer. It is a tool which helps you to find, install, update, and remove software packages. Package managers ensure you always have the right version of software and all the necessary dependencies (other software the package needs to run).
๐ ๏ธ Popular Package Managers:
APT (Advanced Package Tool): Used in Debian-based systems like Ubuntu.
YUM (Yellow-dog Updater Modified) and DNF: Used in Red Hat-based systems like CentOS and Fedora.
Pacman: Used in Arch Linux.
๐ ๏ธ Different Types of Package Managers in Linux
๐ง Debian-based Systems (e.g., Ubuntu)
APT (Advanced Package Tool): The most common package manager for Debian-based distributions.
sudo apt update # Update package list sudo apt install <package_name> # Install a package-
๐ฉ Red Hat-based Systems (e.g., CentOS, Fedora)
YUM (Yellow-dog Updater Modified): Used in older Red Hat-based distributions.
sudo yum update # Update package list sudo yum install <package_name> # Install a package
DNF (Dandified YUM): The next-generation / modified version of YUM.
sudo dnf update # Update package list sudo dnf install <package_name> # Install a package
๐ Arch Linux
Pacman: A package manager specifically for Arch Linux.
sudo pacman -Syu # Update package list and upgrade all packages sudo pacman -S <package_name> # Install a package
๐ง What is systemctl and systemd?
โ๏ธ systemd
systemd is a system and service manager for Linux, responsible for initializing the system and managing services and processes. It offers features like parallel service startup, on-demand activation of daemons, and managing system state.
๐ systemctl
systemctl is the command-line interface used to interact with systemd and to examine and control the state of the โsystemdโ system and service manager. With systemctl, you can:
Start and stop services.
Enable or disable services at boot.
Check the status of services.
๐ Differences between systemctl and systemd
systemd: The actual system and service manager.
systemctl: The tool to control and interact with systemd.
๐ Example Commands:
Start a service:
sudo systemctl start <service_name>
Stop a service:
sudo systemctl stop <service_name>
Check service status:
sudo systemctl status <service_name>
Enable a service:
sudo systemctl enable <service_name>
Disable a service:
sudo systemctl disable <service_name>
๐ณ Example: Installing Docker with Package Managers
Let's have a look at how to Install Docker using Package Managers.
๐ง On Ubuntu
Update your package list:
sudo apt update
Install required packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
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
Set up the Docker 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
Install Docker:
sudo apt update sudo apt install docker-ce
Verify the installation:
sudo systemctl status docker
If the output of this command comes "Service is active / Service is running" means that we have successfully installed Docker.
๐ฉ On CentOS
Update your package list:
sudo yum update
Install required packages:
sudo yum install yum-utils device-mapper-persistent-data lvm2
Set up the Docker repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker:
sudo yum install docker-ce
Start Docker:
sudo systemctl start docker
Verify the installation:
sudo systemctl status docker
๐ Conclusion
Having a good knowledge of Package Managers is important in your DevOps journey because as a DevOps Engineer we are frequently required to install the required softwares and working with different Linux flavors, the knowledge of different types of Package Managers and their usage becomes important. I hope you enjoyed reading the article.
Feel free to explore more and enjoy your journey in the Linux world! ๐