Day 6 Task: Understanding package manager and systemctl

Day 6 Task: Understanding package manager and systemctl


8 min read

What is a package manager in Linux?

๐Ÿ“ฆ๐ŸงIn simple words, a package manager in Linux is like an app store for your computer. It helps you easily find, install, update, and remove software without the need to search the web or deal with messy downloads. It's a convenient way to manage all the software on your Linux system, keeping it organized and up-to-date with just a few clicks or commands.๐Ÿ’ป๐Ÿš€

What is the package?

A package is like a neatly wrapped gift ๐ŸŽ that contains software for your computer. It's a collection of files and instructions that make a specific program work properly on your system.

Imagine you want to install a new cool app on your computer, like a photo editor ๐Ÿ“ธ. Instead of downloading all the necessary files one by one from the internet, a package bundles everything together in an organized way. It includes the main program, its supporting files, and instructions on how to install and run it.

When you use a package manager (like we talked about earlier), it finds the right package for you in its app store ๐Ÿฌ. Then, with a simple command or click, it unwraps the package, sets up the software correctly, and voilร ! You have your shiny new photo editor installed and ready to use. ๐ŸŽ‰

Packages make installing and managing software much easier, as they handle all the behind-the-scenes work, ensuring everything works harmoniously on your computer. So, whenever you want to add or update software, think of packages as those convenient gift boxes that deliver the software goodness right to your digital doorstep! ๐ŸŽ€๐Ÿ’ป๐ŸŽˆ

Different kinds of package managers

  1. ๐Ÿ Python's "pip" Package Manager: Pip is like a Pythonic ๐Ÿ treasure chest that helps you manage Python libraries and packages. It makes it super easy to install, update, and remove Python software, so you can build amazing projects with ease. ๐Ÿ“ฆ๐Ÿ๐Ÿ”ง

  2. ๐Ÿ“ฆ Node.js's "npm" Package Manager: Npm is the friendly ๐ŸŒŸ buddy for Node.js developers. It's like a playground for JavaScript packages ๐ŸŽฎ. With npm, you can fetch and use various libraries to create web applications and server-side magic. ๐ŸŒ๐Ÿ“š๐Ÿ”ฎ

  3. ๐Ÿ—๏ธ GNU Compiler Collection (GCC): GCC is a powerful ๐Ÿš€ toolbox for developers. It includes various compilers for languages like C, C++, and Fortran. It's like having a set of construction tools ๐Ÿ› ๏ธ to build robust software for your Linux system. ๐Ÿ›ก๏ธ๐Ÿฐ๐Ÿ‘ท

  4. ๐Ÿซ Chocolatey Package Manager: Chocolatey is like a sweet ๐Ÿซ treat for Windows users. It brings the joy of package management to the Windows environment. With Chocolatey, you can easily install and update software from the command line. ๐Ÿฌ๐Ÿ–ฅ๏ธ๐Ÿญ

  5. ๐ŸŽ Homebrew for macOS: Homebrew is like a refreshing ๐Ÿบ pint of beer for Mac users. It's a popular package manager that allows you to install and manage open-source software on your macOS system. Cheers to easy software management! ๐Ÿป๐Ÿ๐Ÿ’ป

  6. RPM (Red Hat Package Manager): ๐Ÿ“ฆ

    RPM is the foundation of package management in Red Hat-based distributions like RHEL, CentOS, and Fedora. ๐Ÿ‚

    It stands for "Red Hat Package Manager."

    RPM is used to manage individual software packages in the .rpm format.

    Each RPM package contains compiled software, configuration files, and metadata about the package.

    Popular commands: rpm -i (install), rpm -U (upgrade), rpm -e (erase/remove).

  7. ๐Ÿญ Snap Package Manager: Snap is like a modular ๐Ÿญ factory that packages software with all its dependencies. It provides a way to distribute apps that work across various Linux distributions, making it easier to get the software you need, regardless of your Linux flavor. ๐Ÿ“ฆ๐Ÿ”ง๐Ÿ”จ

  8. APT (Advanced Package Tool): ๐Ÿ“ฆ Used in Debian and Ubuntu distributions. ๐Ÿง APT uses the apt-get command to manage packages. It deals with packages in the .deb format. Popular commands: apt-get install, apt-get update, apt-get remove. ๐Ÿ“

  9. dnf/yum: ๐Ÿ“ฆ DNF (Dandified Yum) is the default package manager in Fedora and RHEL 8+. Yum (Yellowdog Updater Modified) was used in older RHEL and CentOS versions. They manage packages in the .rpm format. Popular commands: dnf install, dnf update, dnf remove. ๐Ÿ‚

  10. Pacman: ๐Ÿ“ฆ Used in Arch Linux and its derivatives. Pacman is known for its simplicity and speed. It handles packages in the .pkg.tar.xz format. Popular commands: pacman -S, pacman -Syu, pacman -R. ๐Ÿน

  11. Flatpak: ๐Ÿ“ฆ Another universal package manager that provides sandboxed applications. Works across various Linux distributions. Flatpak packages use the .flatpak format. Popular commands: flatpak install, flatpak update, flatpak uninstall. ๐Ÿ“ฆ๐Ÿข๐Ÿš€

  12. zypper: ๐Ÿ“ฆ Used in openSUSE Linux. Zypper is efficient and user-friendly. Manages packages in the .rpm format. Popular commands: zypper install, zypper update, zypper remove. ๐Ÿ“ฆ๐Ÿ”๐ŸฆŒ

  13. Portage: ๐Ÿ“ฆ The package manager for Gentoo Linux. It compiles packages from source code, providing high customization. Offers a rich set of options and control over system configuration. Popular commands: emerge, emerge --sync, emerge --unmerge. ๐Ÿ“ฆ๐Ÿ”จ๐Ÿ”ง

  14. Nix: ๐Ÿ“ฆ Used in NixOS, a unique Linux distribution. Nix is purely functional and allows multiple versions of packages to coexist. Provides easy rollback to previous configurations. Popular commands: nix-env -i, nix-env -u, nix-env --uninstall. ๐Ÿ“ฆ๐ŸŽ›๏ธโช

  15. Apk: ๐Ÿ“ฆ The package manager for Alpine Linux, known for its lightweight nature. Manages packages in the .apk format. It focuses on security and simplicity. Popular commands: apk add, apk update, apk del. ๐Ÿ“ฆ๐Ÿ”๏ธ๐Ÿ‚

Tasks 1:

You have to install docker or jenkins in your system from your terminal using package managers

I have written a Script to install Docker using Shell Script

Create file Using Vi


Write the above Script by pressing I key in keyboard.

chmod 700

This type of output will you get after installing Docker.

If you want to check whether Docker is running or not you can :

systemctl status docker

If you want to stop you can use this command :

systemctl stop docker

You can use these commands for various purposes:

Systemd Commands (Used by the Systemd service manager):

  1. systemctl start service_name: Starts a service.

  2. systemctl stop service_name: Stops a service.

  3. systemctl restart service_name: Restarts a service.

  4. systemctl enable service_name: Enables a service to start automatically at boot.

  5. systemctl disable service_name: Disables a service from starting automatically at boot.

  6. systemctl status service_name: Shows the status of a service, whether it's running or stopped.

  7. systemctl is-active service_name: Checks if a service is currently active/running.

  8. systemctl is-enabled service_name: Checks if a service is enabled to start at boot.

  9. systemctl list-units: Lists all active units (services, sockets, devices, etc.).

  10. systemctl list-unit-files: Lists all available unit files (service definitions) on the system.

Examples (assuming 'apache' is the service name):

  • To start Apache web server: sudo systemctl start apache

  • To stop Apache web server: sudo systemctl stop apache

  • To restart Apache web server: sudo systemctl restart apache

  • To enable Apache to start at boot: sudo systemctl enable apache

  • To disable Apache from starting at boot: sudo systemctl disable apache

  • To check the status of Apache: sudo systemctl status apache

  • To see if Apache is active/running: sudo systemctl is-active apache

  • To see if Apache is enabled: sudo systemctl is-enabled apache

  • To list all active units: sudo systemctl list-units

  • To list all available unit files: sudo systemctl list-unit-files

    Remember to use sudo before the commands that require administrative privileges, as most Systemd operations need elevated permissions. ๐Ÿš€๐Ÿ”ง๐ŸŒŸ

Tasks 2:

๐Ÿ”ง systemctl vs. service ๐Ÿ”

Both systemctl and service are commands used in Linux to manage services, but they have some differences in how they interact with Systemd, the service manager. Let's explore them with interactive emojis! ๐Ÿคฉ๐Ÿ”ง๐Ÿง

  1. systemctl: ๐ŸŽ›๏ธ

    • Systemctl is like a modern remote control for Systemd, giving you advanced control over services.

    • It's the preferred method on newer Linux distributions, and it interacts directly with Systemd.

    • Systemctl offers more features, like enabling or disabling services at boot, showing detailed status, and managing dependencies.

  2. service: ๐Ÿ•น๏ธ

    • Service is like an old-school, basic control panel for services.

    • It is a legacy command and works with System V init scripts.

    • It still exists for compatibility with older systems and scripts, but it lacks some advanced features of Systemd.

โš™๏ธ Usage:

  • To check the status of the "docker" service:

    • systemctl: systemctl status docker

    • service: service docker status

Both commands will show whether the "docker" service is running or stopped.

  • To start the "docker" service:

    • systemctl: sudo systemctl start docker

    • service: sudo service docker start

Both commands will start the "docker" service.

  • To enable the "docker" service to start at boot:

    • systemctl: sudo systemctl enable docker

    • service: Not available with the service command.

Here, only systemctl can enable the "docker" service to start automatically during boot.

๐Ÿ‘‰ Recommendation:

  • For newer systems and more functionality, use systemctl for managing services.

  • If you're working on an older system with System V init scripts, you can still use service.

Remember, Systemd and systemctl are becoming the standard on modern Linux distributions, offering more power and flexibility for managing services! ๐Ÿš€๐Ÿ’ช๐Ÿง

๐ŸŒŸ Thank you, dear readers! Your support means the world to me. ๐ŸŒโœจ We're grateful to have you as part of our incredible blog community! ๐Ÿค—๐Ÿ“š Your engagement, likes, and shares fuel my passion to bring for you more inspiring content. ๐Ÿš€๐Ÿ”ฅ Let's continue this amazing journey together! ๐ŸŒˆ๐ŸŒŸ #Gratitude #BlogCommunity #Inspiration ๐Ÿ’ป๐Ÿ“