Skip to main content

Command Palette

Search for a command to run...

Understanding package manager and systemctl

Updated
5 min read
Understanding package manager and systemctl
S

I write blogs about DevOps current and emerging tools/technologies.

#Day7 of #90DaysOfDevopsChallenge

A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like apt-get or pacman.

✅What is a package?

A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.

✅Different kinds of package managers

Package Managers differ based on packaging system but same packaging system may have more than one package manager.

For example, RPM has Yum and DNF package managers. For DEB, you have apt-get, aptitude command line based package managers.

✔️Docker Installation - Complete Step by step Guide

  1. Remove any Docker files that are running in the system, using the following command:

    Command : sudo apt-get remove docker docker-engine docker.io

  2. Check if the system is up-to-date using the following command:

Command : sudo apt-get update

  1. Docker Installation command : sudo apt install docker.io

You’ll then get a prompt asking you to choose between y/n - choose y.

  1. Install all the dependency packages

Command: sudo snap install docker

5. Before testing Docker, check the version installed using the following command: docker --version

6. Pull an image from the Docker hub

command : sudo docker run hello-world

Here, hello-world is the docker image present on the Docker hub.

  1. Check if the docker image has been pulled and is present in your system using the following command: sudo docker images

  2. To display all the containers pulled

    command: sudo docker ps -a

  3. To check for containers in a running state, use the following command:

    command : $ sudo docker ps

You’ve just successfully installed Docker on Ubuntu!

✔️Jenkins Installation - Complete step by step Guide

  1. Java Installation:

Commands : sudo apt-cache search openjdk

sudo apt-get install openjdk-11-jre -y

  1. Check your java version by using the below command :

Java --version

  1. add the repository key to the system:

    command : wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

  2. After the key is added the system will return with OK.

    Next, let’s append the Debian package repository address to the server’s sources.list:

    command : sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

  3. After both commands have been entered, we’ll run update so that apt will use the new repository.

    command : sudo apt update

  4. Finally, we’ll install Jenkins and its dependencies.

    commands : sudo apt install jenkins

  5. Let’s start Jenkins by using systemctl:

    command : sudo systemctl start jenkins

  6. Since systemctl doesn’t display status output, we’ll use the status command to verify that Jenkins started successfully:

Command : sudo systemctl status jenkins

If everything went well, the beginning of the status output shows that the service is active and configured to start at boot:

  1. Opening the Firewall

    command : sudo ufw allow 8080

  2. To check the status use the below command : sudo ufw status

  3. If the status is inactive, as shown in the below screenshot, use the commands : sudo ufw allow OpenSSH

    sudo ufw enable

  4. sudo ufw allow OpenSSH sudo ufw enableCheck ufw’s status to confirm the new rules:

✔️Setting Up Jenkins

To set up your installation, visit Jenkins on its default port, 8080, using your server domain name or IP address: http://your_server_ip_or_domain:8080

In the terminal window, use the cat command to display the password:

We’ll click the Install suggested plugins option, which will immediately begin the installation process.

When the installation is complete, you’ll be prompted to set up the first administrative user. It’s possible to skip this step and continue as admin using the initial password we used above, but we’ll take a moment to create the user.

✔️check the status of docker service in your system (make sure you completed above tasks, else docker won't be installed)

Command : systemctl status docker

To stop the Docker service, you can use the following command in the terminal:

command : sudo systemctl stop docker

This will stop the Docker service immediately. If you want to prevent the service from starting automatically at boot, you can also disable it using the following command: sudo systemctl disable docker

✔️Stop the service jenkins and post before and after screenshots

To check the status

command : sudo systemctl status jenkins

To stop the Jenkins service, you can use the following command in the terminal: sudo systemctl stop jenkins

✔️Read about the commands systemctl vs service

💡systemctl :

The systemctl 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.

Example: systemctl status docker

💡Service :

The service command starts, stop and restart a daemon or services by calling the script. Usually all scripts are stored in /etc/init. d directory. It runs a script in as predictable environment as possible.

Example : service docker status

Conclusion : systemctl is basically a more powerful version of service.

With service you can only do commands related to the service (i.e. status, reload, restart) whereas with systemctl you can use more advanced commands.

Understanding package manager and systemctl