#day7 Task: Understanding package manager and systemctl

What is a package manager in Linux?

  • A package manager in Linux is a software tool that automates the process of installing, updating, configuring, and removing software packages on a Linux system.

  • Linux packages are collections of files that contain compiled code, libraries, documentation, and other resources needed to run a particular piece of software. A package manager makes it easy to find, download, and install packages from a centralized repository of software packages maintained by the Linux distribution.

With a package manager, you can quickly install software on your Linux system without having to manually download, compile, and install each package separately. You can also easily update all the installed packages to the latest versions, and remove packages that are no longer needed.

What is a package?

  • In computer programming, a package is a collection of related modules or libraries that provide a set of functionalities or features that can be used by other software programs. Packages help to organize and modularize code, making it easier to manage and maintain.

  • A package typically contains a set of files and directories that are structured in a particular way, along with some metadata and configuration files. The files within the package can include source code, documentation, test cases, and other resources that are needed to use the package.

  • Packages can be created for a variety of programming languages, including Python, Java, and Ruby. In Python, for example, packages are represented by directories that contain an init.py file, which is executed when the package is imported, along with other Python modules.

Different kinds of package managers:

There are several types of package managers, each designed to manage different types of software packages and dependencies. Here are some common types:

System-level package managers: These package managers are designed to manage software packages at the operating system level. Examples include APT (Advanced Package Tool) for Debian-based Linux distributions, YUM (Yellowdog Updater, Modified) for Red Hat-based Linux distributions, and Homebrew for macOS.

Language-specific package managers: These package managers are designed to manage packages and dependencies for specific programming languages. Examples include npm for Node.js, pip for Python, and gem for Ruby.

Application-level package managers: These package managers are designed to manage packages for specific applications. Examples include Composer for PHP applications, Maven for Java applications, and NuGet for .NET applications.

Cloud-specific package managers: These package managers are designed to manage packages and dependencies for cloud-based applications. Examples include Terraform for infrastructure as code and Helm for Kubernetes.

Package registries: These are centralized repositories that store software packages and their associated metadata, which can be accessed and installed by package managers. Examples include the Python Package Index (PyPI), the Node.js Registry, and the Docker Hub Registry.

Difference between systemctl and systemctl:

systemd is a system and service manager for Linux operating systems, which provides a range of features such as service management, process tracking, logging, and more. On the other hand, systemctl is a command-line utility that is used to control the systemd system and service manager.

Systemd is responsible for initializing the system and managing services during boot time, as well as managing them during runtime. It also provides various other features such as advanced logging capabilities, process tracking, cgroup management, and more. Systemd has replaced the traditional System V init system that was used in earlier versions of Linux.

Systemctl is a command-line utility that provides a convenient way to interact with systemd. It allows users to manage systemd units such as services, sockets, devices, and timers. Systemctl can be used to start, stop, enable, disable, reload, or restart services, as well as check their status and view their logs.

In summary, systemd is the underlying system and service manager for Linux, while systemctl is a command-line tool used to interact with and control systemd.

Tasks :

How to install Docker using package manager in AWS EC2 machine ?

Steps:

  1. Connect to our EC2 instance using SSH.

  2. Update the package index by running the following command:

    ubuntu@ip-172-31-18-16:~$ sudo apt-get update

  3. Install Docker using the below command :

    ubuntu@ip-172-31-18-16:~$ sudo apt-get install docker.io

  4. After the installation is complete, check the Docker version by running the following command:

    ubuntu@ip-172-31-18-16:~$ docker --version

We have successfully installed Docker using the package manager on your AWS EC2 machine.

  1. Check the status of the docker service in our system :

ubuntu@ip-172-31-18-16:~$ sudo systemctl status docker

  1. Stop the docker service in our system :

    ubuntu@ip-172-31-18-16:~$ sudo systemctl stop docker

    1. Start the docker service in our system :

      ubuntu@ip-172-31-18-16:~$ sudo systemctl start docker

Difference between systemctl status docker vs service docker status

systemctl status docker and service docker status are two commands used to check the status of the Docker service on a Linux system, but they differ in their approach and usage.

  • systemctl is a command-line tool used to control the systemd system and service manager on Linux systems. It is used to start, stop, enable, disable, and check the status of system services. systemctl status docker checks the status of the Docker service using systemd. This command provides detailed information about the Docker service, including whether it is running or stopped, its process ID, and other relevant information.

  • service is a command-line tool used to manage services on older Linux systems that use the init system. service docker status checks the status of the Docker service using the init system. This command provides basic information about the Docker service, such as whether it is running or stopped.

In general, systemctl status docker is the preferred command to check the status of the Docker service on modern Linux systems, as it provides more detailed information and is compatible with the systemd system and service manager. However, service docker status can still be used on older Linux systems that use the init system.