Understanding Package Managers and Systemctl in Linux
👩💻 Hey there! I'm a DevOps engineer and a tech enthusiast with a passion for sharing knowledge and experiences in the ever-evolving world of software development and infrastructure. As a tech blogger, I love exploring the latest trends and best practices in DevOps, automation, cloud technologies, and continuous integration/delivery. Join me on my blog as I delve into real-world scenarios, offer practical tips, and unravel the complexities of creating seamless software pipelines. Let's build a strong community of tech enthusiasts together and embrace the transformative power of DevOps!
📦What is a Package Manager in Linux?
A package manager is a software tool designed to manage the installation, removal, and maintenance of software packages on a Linux system. It streamlines the process by resolving dependencies, ensuring that all required components are installed correctly. With a package manager, you can effortlessly install new software, update existing packages, and keep your system up-to-date with the latest releases.
🧰What is a Package?
A package is a bundled software distribution that includes the necessary files, libraries, and metadata required for installation. Packages streamline the installation process and help manage software effectively. They are available in specific formats compatible with the package manager used by the Linux distribution.
🗃️🛠️Different Kinds of Package Managers
APT (Advanced Package Tool):
APT is widely used in Debian-based distributions like Ubuntu and is known for its user-friendly command-line interface. APT is a powerful command-line package management tool providing an interface for better interactive usage. With APT, you can effortlessly install, update, and remove packages using simple commands.
Common APT Commands:
sudo apt install <package-name>: Installs a package and its dependencies.sudo apt upgrade: Upgrades installed packages to their latest versions, where available.sudo apt remove <package-name>: Removes a package from the system.sudo apt search <keyword>: Searches for packages containing the specified keyword in their names or descriptions.YUM (Yellowdog Updater Modified):
YUM, which stands for "Yellowdog Updater Modified," is a package management tool used primarily in Red Hat-based Linux distributions, such as CentOS and Fedora. It simplifies the process of installing, updating, and removing software packages on the system.
Common YUM Commands:
yum install <package-name>: Installs a package and its dependencies.yum update <package-name>: Updates a package to the latest version, along with its dependencies.yum remove <package-name>: Removes a package from the system.yum search <keyword>: Searches for packages containing the specified keyword in their names or descriptions.
🐳🔧Installing Docker and Jenkins via Package Managers
Installing docker on Ubuntu using APT
sudo apt install docker.io -y
docker --version
Installing Jenkins on Ubuntu using APT
Follow the below steps:
Jenkins requires Java to run, let's update Debian apt repositories and install OpenJDK 17
sudo apt update sudo apt install openjdk-17-jre java -versionInstall the Jenkins Long-Term Support release
curl -fsSL https://pkg.jenkins.io/debian-stable/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-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null sudo apt-get update sudo apt-get install jenkinsStart the Jenkins service:
sudo systemctl start jenkinsEnable Jenkins to start on system boot:
sudo systemctl enable jenkins
Jenkins Installed!!!🌐🎉
🔍Check the status of the docker service in your system
systemctl status docker
The output will show you important details about Docker, such as whether it's running, or enabled, and any recent log entries related to its activity.

Stopping the Jenkins Service
systemctl stop jenkins
🔅Understanding systemctl and service commands-
systemctl and service are both commands used in Linux to manage and control system services, but they have different functionalities and purposes.
systemctlCommand:
systemctl is a more modern and powerful command introduced with Systemd, the init system used in many modern Linux distributions. It is the preferred command for managing system services in these distributions. systemctl provides extensive control over services, including starting, stopping, restarting, enabling, disabling, checking the status, and more. It also allows users to manage other aspects of the system, such as timers, targets, and sockets.
systemctl Commands for Starting, Stopping, and Restarting Services:
systemctl start service_namesystemctl stop service_namesystemctl restart service_name
Example- We have already installed docker, Now let's stop the docker service.
systemctl stop docker
serviceCommand:
The service command is a legacy command that has been traditionally used in older versions of Linux distributions and is still available on many systems for backward compatibility. It allows users to start, stop, restart, enable, and disable system services.
Example: To start the Apache web server service:
service apache2 start
💡 Difference between systemctl and service
Main Differences:
serviceis a legacy command, whilesystemctlis the modern and preferred command for managing services in Systemd-based distributions.systemctlprovides more features and options for managing services and other system units.Some older distributions may still use the
servicecommand, while newer ones will usesystemctl.
In general, if you are using a modern Linux distribution that utilizes Systemd, it is recommended to use systemctl for managing services. For older systems, the service command is still functional and can be used. However, the overall trend is towards systemctl as it provides more capabilities and is the standard for managing services in modern Linux distributions.
🌟Conclusion:
By understanding the power of package managers and systemctl, we optimize our Linux experience, ensuring a smooth and well-managed system. From installing essential tools like Docker and Jenkins to managing system services flawlessly.
Continue exploring and experimenting with package managers and systemctl to become a proficient Linux user.
Here's to a future filled with seamless software management and efficient service control in our Linux adventures! 📦🔍⚙️🐧🚀
Happy Learning!!!
