Package Installation & Monitoring Service

·

2 min read

For different Linux distribution, there will be a different Package Manager which helps us to install the packages. For example, if you are using Ubuntu, then you can use apt (Application Package Manager), for CentOS you can use yum and similarly for Redhat you can use rpm (Redhat Package Management).

If you want to know which flavour of Linux you are using then you can run lsb_release -a

Eg: ubuntu@ip-172-31-25-118:~$ lsb_release -a

Output:

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 24.04 LTS

Release: 24.04

Codename: noble

Here we are using Ubuntu 24.04 which was released on April 2024.

If you want to install any package then first you need to get the packages from internet using apt-get command and then update it's index files. Here actual installation is not done.

Eg: ubuntu@ip-172-31-25-118:~$ sudo apt-get update

Now if you want to upgrade those packages (which it gets from internet) to it's latest version then you can run below command

ubuntu@ip-172-31-25-118:~$ sudo apt-get upgrade

Here it installs the package to it's latest version. It takes more time to run.

Now if you want to install nginx, you can run below command

ubuntu@ip-172-31-25-118:~$ sudo apt install nginx

Now if you want to remove the package then you can run

ubuntu@ip-172-31-25-118:~$ sudo apt remove nginx

If you want to check the status of nginx service then we will learn the concept of SystemController (systemctl)

Syntax: systemctl <action> <package-name>

a)To check the status of a service

ubuntu@ip-172-31-25-118:~$ systemctl status nginx

b)To stop the service

ubuntu@ip-172-31-25-118:~$ sudo systemctl stop nginx

c)To start the service

ubuntu@ip-172-31-25-118:~$ sudo systemctl start nginx

d)If you want your service will automatically starts when you reboot your machine

ubuntu@ip-172-31-25-118:~$ sudo systemctl enable nginx

Earlier we were using service command which is same as systemctl command.

Syntax: service <package-name> <action>

systemctl and service command, both are used to manage system services in Linux but their functionality is different.

systemctl is used to inspect and control the state of systemd system and service manager. It used in modern systems and it is used on those systems which systemd will act as a init system.

a)Check the status of service → sudo systemctl status docker

b)Start the Jenkins service → sudo systemctl start jenkins

c)Stop the Docker service → sudo systemctl stop docker

d)Enable the Jenkins service to start at boot → sudo systemctl enable jenkins

service command works with older init systems like SysInit. But still it is available on modern systems which has systemd as a init.

a)Check the status of Docker service → sudo service docker status

b)Start the Jenkins service → sudo service jenkins start

c)Stop the Docker service → sudo service docker stop