Day 7 Understanding Package Manager and Systemctl

Pulkit YadavPulkit Yadav
6 min read

Welcome to Day 7 of our Linux journey! Today, weโ€™ll explore Package Managers and Systemctl. A Package Manager simplifies installing, updating, and removing software, while Systemctl allows us to control system services like starting or stopping them. Understanding these tools will enhance your ability to manage your Linux environment effectively. Letโ€™s dive in!

Understanding Package Managers ๐ŸŒŸ

Package Managers are your best friends when it comes to managing software on Linux! They simplify tasks like installing, updating, and removing software packages, so you donโ€™t have to deal with the hassle of managing files manually. ๐Ÿ› ๏ธโœจ

What is a Package? ๐Ÿ“ฆ

A package is like a gift box of software! It contains everything you need to install and run a program, including executable files, libraries, configuration files, and documentation. Each package has a unique name and version number, making it easy to identify what you have. ๐ŸŽ๐Ÿ”

Why Do We Need Package Managers?

  1. Ease of Use: Forget about the old days of downloading software from multiple websites! With just a simple command, you can install applications quickly. Package Managers do the heavy lifting for you! ๐Ÿš€๐Ÿ’ป

  2. Dependency Management: Many software packages rely on other packages (called dependencies) to work correctly. Package Managers automatically figure this out, ensuring that everything needed is installed without you lifting a finger. ๐Ÿ”—๐Ÿค–

  3. Updates: Keeping your software up-to-date is super important for security and performance! With a Package Manager, you can check for updates and upgrade all your installed packages with a single command, keeping your system secure and running smoothly. ๐Ÿ”„๐Ÿ”’

  4. Purging: If you decide you donโ€™t need a package anymore, no worries! Package Managers can purge it for you. This means they not only uninstall the software but also clean up any leftover configuration files, keeping your system tidy! ๐Ÿงนโœจ

  5. Repositories: Package Managers rely on repositories, which are like online libraries filled with software packages. When you install software, it pulls the latest version from these repositories, ensuring you always have the best and most compatible software available. ๐ŸŒ๐Ÿ“š

How to Use Package Managers ๐Ÿ› ๏ธ

Using a package manager is straightforward and makes managing software on your Linux system a breeze! Hereโ€™s a step-by-step guide on how to install, update, and purge software packages.

Updating and Upgrading Software ๐Ÿ“ˆ

Before installing new software, itโ€™s a good idea to update your package manager and upgrade your existing packages. This ensures you have the latest information about available software and that your current packages are up-to-date.

sudo apt update

sudo apt upgrade

Why Update and Upgrade?

  • Update: This command checks for updates to the list of available packages but doesnโ€™t install anything. It ensures your package manager knows about the latest software versions.

  • Upgrade: This command actually installs the latest versions of the packages you already have on your system. It ensures you have the newest features and security updates.

Installing Software ๐Ÿ–ฅ๏ธ

Once your system is updated, you can install new software. For example, if you want to install nginx, a popular web server, you would run:

Next, if you want to install Docker, a platform for developing, shipping, and running applications in containers, you would run:

Purging Software โŒ

If you ever need to remove a package completely, including its configuration files, use the purge command. For example, to remove nginx completely, you would run:

  1. APT (Advanced Package Tool) - Ubuntu OS:

    • Common Commands:

      • Install:

        • sudo apt install nginx

        • sudo apt install docker.io

      • Update: sudo apt update

      • Upgrade: sudo apt upgrade

      • Purge: sudo apt purge nginx

  2. YUM (Yellowdog Updater Modified) - CentOS:

    • Common Commands:

      • Install:

        • sudo yum install nginx

        • sudo yum install docker

      • Update: sudo yum update

      • Purge: sudo yum remove nginx (Note: YUM doesn't have a direct purge command, but it effectively removes packages.)

    • Details: YUM handles .rpm packages and can automatically resolve dependencies for installations.

  3. DNF (Dandified YUM) - Fedora/RHEL 8:

    • Common Commands:

      • Install:

        • sudo dnf install nginx

        • sudo dnf install docker

      • Update: sudo dnf update

      • Purge: sudo dnf remove nginx (Similar to YUM, it effectively removes packages.)

    • Details: DNF is the next-generation version of YUM, providing better performance and enhanced dependency management.

Conclusion ๐Ÿ“

Learning how to use Package Managers is very important for anyone using Linux. They help you easily manage software on your computer, whether you're installing new applications, updating them, or removing ones you no longer need. By getting to know these tools, you'll make your Linux experience smoother and more enjoyable. Embrace Package Managers to get the most out of your system!

Understanding Systemctl and Service Commands

1. What Are They?

  • Systemctl: This command is used in newer Linux systems that use systemd to manage services. It gives you many options for controlling system services and the overall system.

  • Service: This is an older command used in systems that use the SysV init system. It helps you manage services but with fewer options than systemctl.

2. Key Differences

  • Functionality:

    • Systemctl can do more! It not only starts and stops services but also checks their status, enables them to start at boot, and more.

    • Service is simpler. It mainly starts, stops, and checks the status of services.

  • Command Structure:

    • Systemctl uses a consistent command format. For example

      systemctl [action] [service]

    • Service has a more straightforward but less flexible format:

      service [service] [action]

      3. Common Commands

      • Checking Service Status:

        • With systemctl

Command:- sudo systemctl start docker

Command:- sudo service docker start

Stopping a Service:

  • With systemctl

Command:- sudo systemctl stop docker

With service:

Command:- sudo service docker stop

Check Service Status:

  • Using systemctl:

Using service:

4. When to Use Each Command

  • Use systemctl if you are on a system that supports systemd, as it provides more features and better control over services.

  • Use service if you are on an older system or if you're running scripts that still use this command.

Conclusion

Understanding the differences between systemctl and service is essential for effectively managing services on your Linux system. While systemctl is more versatile and tailored for modern systems, service remains a useful command for simpler tasks or older systems. Choose the one that best fits your needs.

Thank you for taking the time to read this blog! We hope you found the information about package managers and Systemctl helpful. Mastering these tools is crucial for effective software management in Linux. Happy learning, and see you in the next blog!

1
Subscribe to my newsletter

Read articles from Pulkit Yadav directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pulkit Yadav
Pulkit Yadav

DevOps Enthusiast | Exploring Cloud & Automation Iโ€™m an aspiring DevOps professional passionate about cloud computing, automation, and CI/CD pipelines. Iโ€™m currently gaining hands-on experience with tools like AWS, Docker, Kubernetes, Jenkins and GitLab CI/CD, Terraform, Ansible, and more. My focus is on improving development and deployment processes through continuous learning and practical application. Alongside my learning journey, I share my insights and experiences through blogs to help others who are exploring the same path. I believe in learning together and growing by sharing knowledge, and Iโ€™m excited to connect with like-minded individuals in the field. Letโ€™s collaborate, share ideas, and grow together!