Table of contents
Package Manager in Linux
Package Manager is a tool used to install, update, and remove software packages on Linux-based OS. It automates the process of managing software packages and their dependencies, and it makes life easy for users to install and update software.
There are several package managers available in Linux such as below.
APT (Advance Package Tool) : APT is used by Debian-based distributions such as Ubuntu, and Linux Mint, and is known for its ease of use and powerful command-line interface.
Yellowdog Updater, Modified (YUM): YUM is used by Red Hat-based distributions, such as Fedora and CentOS, and is known for its speed and efficiency in handling large package sets.
Pacman: Pacman is used by Arch Linux and is known for its simplicity and flexibility.
Zypper: Zypper is used by SUSE Linux and is known for its robustness and reliability.
These package managers are work by accessing the reposetories which are servers that host packages for distribution. The package manager downloads packages from the repository, resolves any dependencies, and installs them on the system. The package manager also manages the removal and updating of packages.
Overall, package managers are an essential part of the Linux ecosystem, making it easy to manage software packages and ensuring that the system is up-to-date and secure.
What is Package
A package refers to a software bundle that contains all the files necessary for installing and running a particular software application. A package typically includes the software's executable files, libraries, configuration files, and other resources that the software needs to function properly.
Packages are designed to simplify the installation and maintenance of software applications on a Linux-based system. Instead of having to manually download and install each software component separately, users can use a package manager to install packages with just a few simple commands.
Different Linux distributions use different packaging formats and tools. For example, Debian-based distributions, such as Ubuntu and Debian, use .deb packages and the Advanced Packaging Tool (APT) for package management, while Red Hat-based distributions, such as Fedora and CentOS, use .rpm packages and the Yellowdog Updater, Modified (YUM) for package management.
In summary, a package in Linux is a self-contained bundle of software that simplifies the installation and maintenance of software applications on a Linux-based system.
Now let's do some hands-on and try to install Docker and Jenkins through the package manager.
Let's start with the Docker installation first.
- First we will update our package database
sudo apt-get update
Install the necessary packages to allow APT to use a repository over HTTPS: or you just go the official site of docker and find below command.
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
Add Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker APT repository to your system's software repository list:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the package database again:
sudo apt-get update
Install the latest version of Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
Verify that Docker is installed and running by running the following command:
sudo docker run hello-world
Now let's start with Jenkins Installation
Step 1: Install Java
Jenkins needs Java for running, but it doesn't include certain distributions by default, and Java versions of Jenkins are incompatible.
Multiple Java implementations are available to you. OpenJDK is currently the most popular one, which we will use in this guide.
Being an open-source Java application, Jenkins requires the installation of OpenJDK 8 on your system. The apt repositories can directly access OpenJDK 8.
The installation of OpenJDK from standard repositories is recommended.
$ sudo apt update
$ sudo apt install openjdk-8-jdk
The download and installation will be requested. Press the "Y" button and press the Enter button.
Java 8 will be installed on your system. Now we can install Jenkins package as we have our requirements already.
Step 2: Install Jenkins
Add the framework repository key
$ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add
Link the repository of packages to the sources.list of the server.
$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
When both are in place, upgrade to apt to use the new repository
$ sudo apt update
Now install Jenkins
$ sudo apt install jenkins
Step 3: Start Jenkins
You can start Jenkins by systemctl
$ sudo systemctl start jenkins
As systemctl does not display performance, you can use the status command to check that Jenkins has successfully launched:
$ sudo systemctl status jenkins
Output should be like below.
jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Sat 2023-04-02 00:34:17 IST; 26s ago
Step 4: Opening the Firewall
Jenkins works by default on port 8080, so let's open the port with ufw.
$ sudo ufw allow 8080
Check ufw’s status
$ sudo ufw status
Output should be like below.
Status: active
To Action From
-- ------ ----
8000 ALLOW Anywhere
CUPS ALLOW Anywhere
27017 ALLOW Anywhere
27017 ALLOW 192.168.2.85
If the firewall is inactive, the following commands will allow OpenSSH and turn it back on.
$ sudo ufw allow OpenSSH
$ sudo ufw enable
Step 5: Setting Up Jenkins
To set up installation, visit Jenkins on its default 8080 port with your server domain name or IP address: http://your_server_ip_or_domain:8080
You should see the Unlock Jenkins screen, which displays the initial password's location
You can use the cat command to display the password
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the alphanumeric terminal 32-character password and paste into the Administrator Password field, then click Continue. just like below
0aaaf00d9afe48e5b7f2a494d1881326
Below screen shows the ability to install or select certain plugins.
Click on the option to install proposed plugins to start the installation process immediately.
When the installation is done, the first administrative user will be prompted. You can save this step and use your initial password to continue as an Admin. However, we will take some time to create the user.
The Jenkins default server is NOT encrypted to prevent data from being protected. Use the Nginx Reverse Proxy on Ubuntu 18.04 to configure Jenkins with SSL. This protects the information of users and builds transmitted through the web interface.
You will see a configuration instance page, which asks you to confirm your Jenkins instance's URL of choice. Confirm either your server's domain name or the IP address of your server.
Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"
Hit the Start using the Jenkins button and it will take you to the Jenkins dashboard.
Congratulations! You have completed the installation of Jenkins.
Difference between systemctl and service.
systemctl
and service
are both commands used in Linux systems to manage services.
systemctl
is a more modern and powerful command that has replaced the older service
command in newer versions of Linux. It is a systemd utility used to control system services and manage the system's behavior.
With systemctl
, you can start, stop, restart, reload, enable, disable, mask, and unmask services. It also provides more detailed information on the status and configuration of the service, including whether it is running or not, and logs related to it.
On the other hand, service
is a legacy command that is still available in most Linux distributions. It is used to start, stop, restart, and check the status of system services. However, service
is not as powerful as systemctl
and does not provide as much information about the service's status and configuration.
In summary, while service
is still available and works well for managing services in some cases, systemctl
is a more advanced and flexible command that is better suited for managing services in modern Linux systems.
I hope this article helps you!!
Happy Learning !!
Saif Ali
Senior Software Engineer