Day7 of #90daysofdevops | Understanding package manager and systemctl

Day7 of #90daysofdevops | Understanding package manager and systemctl

ยท

6 min read

What is a package manager in Linux? ๐Ÿง

In simpler words, 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 as an application, but it could be a GUI application, command-line tool, or 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 the packaging system, but the 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 and aptitude command-line-based package managers. ๐Ÿ“ฆ๐Ÿ“‹

Having a package manager in Linux makes software installation and management a breeze! ๐ŸŒฌ๏ธ๐Ÿ’จ Whether you're a command-line guru or a fan of graphical interfaces, Linux offers a variety of package managers to suit your preferences. So go ahead and explore the vast world of software packages in the Linux ecosystem! ๐ŸŒ๐Ÿง

Write a small blog or article to install these tools using package managers on Ubuntu and CentOS

๐Ÿš€ DevOps Magic: Installing Tools with Package Managers on Ubuntu and CentOS ๐Ÿง๐Ÿ’ป

As a DevOps enthusiast, you know that choosing the right tools can make all the difference in streamlining your development and deployment processes. Thankfully, package managers come to our rescue, simplifying the installation and management of various software on Linux distributions like Ubuntu and CentOS. Let's explore how to wield this DevOps magic on both of these popular distros! ๐ŸŽฉโœจ

๐Ÿ–ฅ๏ธ Ubuntu: A Rock-Solid Foundation ๐Ÿ›๏ธ

Ubuntu, known for its user-friendly interface and wide community support, relies on the APT (Advanced Package Tool) package manager. Let's see how we can wield this tool to install some essential DevOps goodies. ๐Ÿ› ๏ธ๐Ÿง

1. Docker: Containerization Made Easy ๐Ÿณ๐Ÿ“ฆ

With Docker, you can pack your applications in containers, making them portable and easy to deploy. To install Docker on Ubuntu, execute the following commands:

sudo apt update
sudo apt install docker.io

2. Jenkins: The Automation Guru ๐Ÿค–๐Ÿ“œ

Jenkins, the automation powerhouse, is a must-have for any DevOps workflow. To get Jenkins up and running on Ubuntu, use these commands:

sudo apt update
sudo apt install jenkins

๐Ÿง CentOS: The Reliable Workhorse ๐Ÿ‡๐ŸŒพ

CentOS, renowned for its stability and long-term support, relies on YUM (Yellowdog Updater Modified) as its trusty package manager. Let's harness its power to install some crucial DevOps tools. ๐Ÿ› ๏ธ๐Ÿ‚

1. Docker: The Container Enchanter ๐Ÿณ๐Ÿ“ฆ

Install Docker on CentOS with the following commands:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

2. Jenkins: The Master of CI/CD ๐Ÿค–๐Ÿ”ง

For Jenkins on CentOS, perform these incantations:

sudo yum install -y java-11-openjdk-devel
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
sudo yum install -y jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins

๐ŸŒŸ Congratulations, DevOps Wizard! ๐Ÿง™๐Ÿปโ€โ™‚๏ธ๐ŸŒ 

By harnessing the power of package managers on Ubuntu and CentOS, you've unleashed the full potential of your DevOps journey. Docker for containerization and Jenkins for automation is just the beginning of your magical toolset. As you continue your DevOps quest, remember that package managers are your trusted allies, ensuring a smooth and efficient software installation experience. ๐ŸŒˆ๐Ÿ’ซ

Embrace the magic of DevOps, and may your deployments be swift, your pipelines be robust, and your infrastructure be rock-solid! Happy DevOpsing! ๐Ÿš€๐Ÿ”ง

Docker Installation results -->

Jenkins Installation results -->

Once the installation is done, we need to go to Security group settings and allow port 8080 since Jenkin runs on the 8080 port. Once we do that, copy the public IP of our EC2 machine and paste it into the browser with port 8080 and you'll be able to access Jenkins there. When it asks for an administrative password, just copy the path /var/lib/jenkins/secrets/initialAdminPassword and see the content using the cat command and copy that password.
Create your user & Install the suggested plugins.

Here you go - Jenkins is ready to use and explore.
Reference article to install Jenkins - youtube.com/watch?v=lRpS2CovMrs & pkg.jenkins.io/debian-stable
Jenkins installation YouTube video link

/systemctl and systemd

systemctl is used to examine and control the state of the โ€œsystemdโ€ system and service manager. systemd is a system and service manager for Unix-like operating systems(most of the distributions, not all).

check the status of the docker service in your system

systemctl status docker


service docker status

stop the service Jenkins and post before and after screenshots

  1. When Jenkins service is in a running state

  2. When Jenkins service is in an inactive state

Read about the commands systemctl vs service

๐Ÿ”ง DevOps Magic: Understanding systemctl vs. service Commands ๐Ÿง™๐Ÿปโ€โ™‚๏ธ๐Ÿ”

๐Ÿ•น๏ธ service: The Old Guardian ๐Ÿฐ๐Ÿ‘ด

service has been a long-standing guardian of service management in Linux. It is compatible with traditional init systems such as SysVinit. In a world where init scripts ruled the land, service was the go-to spellcaster to start, stop, restart, or check the status of a service. Its incantations were straightforward to remember:

  • To start a service:

      sudo service serviceName start
    
  • To stop a service:

      sudo service serviceName stop
    
  • To restart a service:

      sudo service serviceName restart
    
  • To check the status of a service:

      sudo service serviceName status
    

๐Ÿง™โ€โ™‚๏ธ systemctl: The Modern Enchanter ๐Ÿง™๐Ÿปโ€โ™‚๏ธ๐Ÿฐ

With the advent of newer init systems like systemd, a new enchantment was introduced: systemctl. This modern enchanter has become the preferred method for service management in most modern Linux distributions. Its powers are vast, offering more control and versatility over services. Here's how systemctl casts its spells:

  • To start a service:

      sudo systemctl start serviceName
    
  • To stop a service:

      sudo systemctl stop serviceName
    
  • To restart a service:

      sudo systemctl restart serviceName
    
  • To check the status of a service:

      sudo systemctl status serviceName
    
  • To enable a service to start at boot:

      sudo systemctl enable serviceName
    
  • To disable a service from starting at boot:

      sudo systemctl disable serviceName
    
  • To reload the configuration of a service without stopping it:

      sudo systemctl reload serviceName
    

๐Ÿง™โ€โ™€๏ธ Choosing the Right Spell ๐Ÿง™๐Ÿปโ€โ™€๏ธ๐Ÿ”ฎ

Both service and systemctl are powerful allies in your DevOps journey. While service works with traditional init systems, systemctl empowers you in the realm of systemd. When working with older systems or scripts, you may find service more fitting. However, for modern systems and distributions, systemctl is your go-to choice.

With the knowledge of these magical commands, you can confidently navigate your Linux environment, controlling services like a true DevOps sorcerer. Combine their powers wisely, and may your systems run smoothly and reliably in the realm of DevOps! ๐ŸŒŒ๐Ÿง™๐Ÿปโ€โ™‚๏ธ๐Ÿ”งโœจ

Thanks for reading the blog & do share them with someone in need :)

Please share your views and suggestions, they are always welcome.

See you then in the next blog.

Happy learning :)

ย