Day-07 of 90DaysofDevOps A Step-by-Step Tutorial on Understanding Package Managers
what is package ?
What is a package manager in Linux?
How does the package managers work?
systemctl and systemd
Task : You have to install Docker and Jenkins in your system from your terminal using package managers
Task 2 : Check the status of the Docker service in your system
Task 3 : Stop the Service Jenkins
Conclusion
What is package ?
In Linux distributions, a “package” refers to a compressed file archive that contains all the files that come with a particular application. The files are usually stored in the package according to their relative installation paths on your system. Most packages also include installation instructions for the OS, as well as a list of all other packages that are dependencies (prerequisites required for installation).
Common types of Linux packages are .deb, .rpm, and .tgz. Because Linux packages usually do not contain the dependencies required for installation, many Linux distributions use package managers that automatically read dependency files and download the required packages before proceeding with the installation. Some examples of package managers are APT, YUM, and Pacman.
what is a package manager in Linux?
In simpler terms, a package manager is a tool that allows users to install, remove, update, configure, and manage software packages on an operating system. The package manager can be a graphical application such as Software Center or a command line tool such as apt-get or pacman.
I use the term "package" frequently in tutorials and articles on It’s FOSS. To understand the package manager, you need to know what a package is.
How does the package manager work?
Almost all Linux distributions have software repositories, which are basically a collection of software packages. Yes, there can be more than one repository. The repositories contain software packages of different types.
Repositories also have metadata files that contain information about the packages, such as the name of the package, the version number, the description of the package, and the name of the repository, etc. You can see this when you use the apt show command in Ubuntu/Debian.
Your system’s package manager interacts with the metadata first. The package manager creates a local cache of the metadata on your system. When you run the package manager's update option (e.g., apt update), it updates this local cache of metadata by pointing to metadata from the repository.
When you run your package manager's install command (for example, apt install package_name), the package manager refers to this cache. If it finds the package information in the cache, it uses the Internet connection to connect to the appropriate repository and downloads the package first before installing it on your system.
A package can have dependencies. This means that it may require other packages to be installed. The package manager often takes care of the dependencies and automatically installs them along with the package you are installing.
Systemctl and systemd
Managing system services and resources on Linux systems is traditionally a complicated and time-consuming task. This is where Linux systemd comes into play. In this article, you will learn what systemd is, what role it plays in Linux systems and how it is used to manage software.
systemd is a system and service manager that provides a more efficient and reliable way to manage system services and resources. Many Linux distributions such as Ubuntu, Debian, etc. use systemd, as it has become the default system and service manager for Linux systems in recent years. It is worth noting that some older Linux distributions may not use systemd and instead use other system and service managers.
systemd initializes services in parallel, which means that it can significantly reduce startup times. It also manages dependencies automatically, so you don’t have to worry about custom scripts. This saves you a lot of trouble when working in a Linux environment. Moreover, it is also more secure than its predecessor SysVinit. SysVinit is simple, but requires more effort, such as writing custom scripts to manage software and services. Also, the startup time is much slower.
Now we know what systemd is, but what is systemctl?
systemctl is a command-line utility used to interact with systemd. It is the main tool that system administrators use to manage systemd services and resources. You can use systemctl to start, stop, restart, enable, disable, and check the status of systemd services.
Here is an example that illustrates the relationship between systemd and systemctl:
sudo systemctl start service_name
sudo systemctl stop service_name
sudo systemctl restart service_name
sudo systemctl enable service_name
sudo systemctl disable service_name
Task : You have to install Docker and Jenkins in your system from your terminal using package managers
Commands for installing Docker :
sudo apt update
sudo apt install docker.io
docker version (To check the version of the docker)
sudo systemctl start docker
sudo systemctl enable docker
Commands for installing Jenkins
- Add the Jenkins repository key and source list
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Install Jenkins:
sudo apt update
sudo apt install jenkins
Start Jenkins:
sudo systemctl start jenkins
sudo systemctl enable jenkins
Task 2 : Check the status of the Docker service in your system
sudo systemctl status docker
Task 3 : Stop the Service Jenkins
To stop the Jenkins service, you must access the server running Jenkins and perform the actions required for your system. Typically, you can stop the Jenkins service from the command line. Here are general instructions for stopping the Jenkins service on Unix/Linux systems:
sudo service jenkins stop
Conclusion
Congratulations on completing day 7 of the #90DaysOfDevOps challenge! Today we dove into the world of packages and package managers and understood their importance in the Linux ecosystem. Exploring different package managers and mastering systemctl and systemd has enabled us to manage services effortlessly. With Docker and Jenkins installed using package managers, we embraced simplicity and automation. You can now monitor Docker's status and stop Jenkins effortlessly. Finally, we learned the difference between systemctl and service to ensure proper service management. Keep up the good work and look forward to more exciting adventures!
I also received comprehensive training in various aspects of DevOps methodologies, including continuous integration, continuous deployment, and infrastructure automation. Stay connected with me for more interesting articles about Cloud and DevOps by following me on Hashnode,
LinkedIn (linkedin.com/in/vedant-adhe-4683b0192) and
GitHub (github.com/VedantAdhe)
Connect Vedantadhe19@gmail.com
Thank You For Reading! Continue to Support Us, Learn From Each Other and Grow Together
Subscribe to my newsletter
Read articles from Vedant Adhe directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by