Day 7 - Package Manager, Systemctl and Services

Day 7 - Package Manager, Systemctl and Services

What is a Package Manager in Linux?

In simpler words, A package manager keeps track of what software is installed on your computer and allows you to easily install new software, upgrade software to newer versions, or remove software that you previously installed.

A package manager works with packages, data within archive files, and software distributions.

What is a Package?

A package in Linux is a compressed software archive file containing all the files included with a software application that provides any functionality. Packages can be a command-line utility, GUI application, or software library. This process is the same as installing any application, software, or utility in Windows.

In short, Packages include metadata like the name of the software, description of its objective, checksum (a cryptographic hash function preferably), dependency list, vendor, and version number essential for the software to properly run.

Package Manager Tools

However, there are many package manager tools present like dpkg, apt, yum, rpm, dnf, and pacman.

We will deep dive into apt . So, Let's begin!!!

Advanced Packaging Tool(APT)

APT is the most widely used tool and the default package manager available in Ubuntu and other Debian-based distros.

sudo apt install package_name -> To install a package
sudo apt remove package_name -> To remove a package
However, this doesn’t remove the dependencies and package configurations.
sudo apt purge package_name -> To completely remove the package
sudo apt autoremove -> To remove any leftover dependencies
sudo apt update -> To gets a copy of the latest version of all the packages installed in our system from the repositories.
NOTE: This does not upgrade any packages and only fetches the latest version of the package.
sudo apt upgrade -> To check the list of available upgrades and then upgrade the packages one by one.
sudo apt upgrade package_name -> To upgrade one specific package as per the requirement

What are the Various Packaging Formats in Linux?

Various vendors provide their package manager and package format. Some package managers do allow the usage of multiple packaging formats to be used. Some of the prevalent packaging formats include:

  • RPM packages (.rpm): The .rpm package extension was designed and developed by the Red Hat Linux distribution and used in the Red Hat Package Manager (RPM)

  • Debian packages (.deb): The .deb package was designed and developed by the Debian Linux distribution. They are majorly used in Debian-based Linux and distros.

  • TAR archives (.tar): The .tar format is short for Tape Archive. This is just for creating an archive or combination of multiple files and directories into one file. Tar archives do not compress the consisting files and directories.

  • TGZ archives (.tgz): The .tgz format is Tar archives, except for the difference that files in tgz archives are compressed using the GNU Zip compression technique. The result is a compressed archive file and thus less in size.

  • GZip Archives (.gz): The .gz archives are created after direct compression using the GZIP Utility.

systemctl

systemctl is used to examine and control the state of the “systemd” system and service manager.
systemd is a system and service manager for Unix-like operating systems (most of the distributions, not all). As the system boots up, the first process created, i.e. init process with PID = 1, is the system that initiates the userspace services.

The system command manages both system and service configurations, enabling administrators to manage the OS and control the status of services. Further, systemctl is useful for troubleshooting and basic performance tuning.

systemctl [command] [service]
[command] = The action we want to perform (start, stop, enable, disable, etc.)
[service] = The name of the service we want to perform the action on.
systemctl start [service] -> To start system service.
systemctl stop [service] -> To stop system service.
systemctl enable [service] -> For enabling services.
systemctl disable [service] -> For disabling services.
systemctl status [service] -> For viewing status of services.
systemctl restart [service] -> To restart the services.
systemctl reload [service] -> For reloading the services.

Services

SysVInit is the classic initialization process in Linux. The initialization process relies on the individual service to install relevant scripts on the /etc/init.d directory. Additionally, the scripts must support the standard commands such as start, stop, and status.

One of the main characteristics of this init system is that it is a start-once process and does not track the individual services afterwards.

The service command is used for running these init scripts from the terminal.

service [servicename] [command]
[command] = The action we want to perform (start, stop, enable, disable, etc.)
[servicename] = The name of the service we want to perform the action on.

Conclusion

In conclusion, Package Managers, systemctl, and services play crucial roles in the efficient management and operation of Linux systems.

-> Package managers simplify the installation, removal, and updating of software packages, ensuring a streamlined and organized system.
-> systemctl, as a powerful command-line tool, provides a centralized control mechanism for managing services and daemons, allowing users to start, stop, restart, enable, or disable them with ease.
-> services, in turn, are the background processes or daemons that run on a Linux system, providing essential functionality.

Together, these tools contribute to the stability, security, and overall functionality of a Linux environment, making system administration more accessible and effective for users.

*👆The information presented above is based on my interpretation. Suggestions are always welcome.*😊

~Smriti Sharma✌