What is a Package manager?
A package manager is a software tool that helps you install, update, and remove software packages on your Linux system. It provides an easy way to manage software on your system, by handling all the dependencies and configurations for you.
How do Package Managers Work?
Package managers in Linux work by downloading software packages from a central repository. A repository is a collection of software packages that are maintained by a specific organization or community. Each package in the repository is associated with metadata that includes information about the package, such as its name, version, and dependencies.
When you use a package manager to install software, it checks the repository for the package and downloads it along with any dependencies that the software requires. The package manager then installs the software and sets up any necessary configurations.
Different Package Managers in Linux
There are several package managers available in Linux, each with their own strengths and weaknesses. Some of the most popular package managers include:
APT: Advanced Package Tool (APT) is a package manager used by Debian, Ubuntu, and other Debian-based distributions.
YUM: Yellowdog Updater, Modified (YUM) is a package manager used by Red Hat, CentOS, and other Red Hat-based distributions.
Pacman: Pacman is a package manager used by Arch Linux and its derivatives.
Zypper: Zypper is a package manager used by SUSE Linux and its derivatives.
Installing Docker in your system from your terminal using package managers.
To install Docker in your system on Ubuntu or CentOS, open your terminal and use the following commands:
Installing Docker on Ubuntu
Update the apt package index:
$sudo apt update
Install packages to allow apt to use a repository over HTTPS:
$sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker’s official GPG key:
$curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Set up the stable repository:
$sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the apt package index again:
$sudo apt update
Install the latest version of Docker:
$sudo apt install docker-ce
Check Docker installation:
$sudo systemctl status docker
Installing Docker on CentOS
Update the yum package index:
$sudo yum update -y
Install required packages:
$sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Set up the stable repository:
$sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install the latest version of Docker:
$sudo yum install docker-ce -y
Start Docker:
$sudo systemctl start docker
Enable Docker to start on boot:
$sudo systemctl enable docker
Installing Jenkins in your system from your terminal using package managers.
To install Jenkins in your system on Ubuntu or CentOS, open your terminal and use the following commands:
Installing Jenkins on Ubuntu
Update the apt package index:
$sudo apt update
Jenkins requires Java to run so, to install java:
$sudo apt-get install openjdk-11-jdk -y
Add the Jenkins Debian repository key:
$curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Add the Jenkins repository:
$sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Update the apt package index again:
$sudo apt update
Install Jenkins:
$sudo apt install jenkins -y
Start the Jenkins service:
$sudo systemctl start jenkins
Enable Jenkins to start on boot:
$sudo systemctl enable jenkins
Open the firewall for Jenkins (default port 8080):
$sudo ufw allow 8080
Access Jenkins through a web browser at
http://your_server_ip_or_domain:8080
.
Installing Jenkins on CentOS
Update the yum package index:
$sudo yum update -y
Jenkins requires Java to run so, to install java:
$sudo yum install java-11-openjdk-devel -y
Add the Jenkins repository:
$sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo $sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Install Jenkins:
$sudo yum install jenkins -y
Start the Jenkins service:
$sudo systemctl start jenkins
Enable Jenkins to start on boot:
$sudo systemctl enable jenkins
Open the firewall for Jenkins (default port 8080):
$sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp $sudo firewall-cmd --reload
Access Jenkins through a web browser at
http://your_server_ip_or_domain:8080
.
What is systemd?
systemd
is a system and service manager that provides a central way to manage system services and processes. It replaces the traditional init system used by most Linux distributions.
Benefits of systemd
:
Faster boot times
Improved process management
Improved service management
Better logging and monitoring capabilities
Enhanced security features
systemd
is designed to be backwards compatible with the traditional init system, so most of the commands and tools you're familiar with (such as service
, chkconfig
, and init
) can still be used.
What is systemctl?
systemctl
is a command-line tool used to control the systemd system and service manager. It allows you to manage and control various aspects of the system's services, including starting, stopping, enabling, disabling, and reloading services.
Some common commands that you can use with systemctl
include:
systemctl start <service>
: Starts a servicesystemctl stop <service>
: Stops a servicesystemctl restart <service>
: Restarts a servicesystemctl enable <service>
: Enables a service to start automatically at bootsystemctl disable <service>
: Disables a service from starting automatically at bootsystemctl status <service>
: Displays the status of a service
What is service command?
The service
command in Linux is used to manage system services. It allows you to start, stop, restart, enable, disable, and check the status of services that are managed by the system's init system.
The basic syntax for using the service
command is:
$sudo service <service-name> <action>
where <service-name>
is the name of the service you want to manage and <action>
is the action you want to perform on the service.
Here are some common actions that you can perform with the service
command:
start
: Starts a servicestop
: Stops a servicerestart
: Restarts a servicereload
: Reloads the configuration of a servicestatus
: Displays the status of a serviceenable
: Enables a service to start automatically at bootdisable
: Disables a service from starting automatically at boot
Note:
service
command is being phased out in favor ofsystemctl
andsystemd
on newer Linux distributions. However, it is still supported on many systems and can be a useful tool for managing services.
The commands of systemctl vs service
Both systemctl and service are used to control services, but the systemctl is new and more powerful.
The commands to check Docker status using systemctl and service are:
systemctl:
$sudo systemctl status docker
service:
$sudo service docker status
Commands of systemctl:
- To start a service:
$sudo systemctl start <service_name>
- To stop a service:
$sudo systemctl stop <service_name>
- To restart a service:
$sudo systemctl restart <service_name>
- Check the status of a service:
$sudo systemctl status <service_name>
Commands of service:
- To start a service:
$sudo service <service_name> start
- To stop a service:
$sudo service <service_name> stop
- To restart a service:
$sudo service <service_name> restart
- Check the status of a service:
$sudo service <service_name> status
That's all from me for today! I hope you found this blog interesting. Any recommendations and improvements are most welcome! Make sure to like and follow!
Happy Learning!