#Day7: Understanding Package Manager and SystemCtl

#Day7: Understanding Package Manager and SystemCtl

ยท

6 min read

๐Ÿง๐Ÿ“ฆ All About Package Managers in Linux! ๐Ÿš€

Hey there, fellow Linux explorers! ๐Ÿค— Today, we're diving into the world of package managers in Linux. ๐ŸŒ If you've ever wondered how software gets installed and managed on your Linux system, you're in the right place! ๐ŸŽ‰

๐Ÿค” What is a Package Manager?

Imagine you want to download and install new apps or programs on your computer. In the Linux world, we have these cool tools called "Package Managers" that make this process super easy! ๐Ÿ˜Ž A package manager is like a magic genie ๐Ÿงžโ€โ™‚๏ธ that fetches, installs, and updates software for you with just a few simple commands! ๐Ÿ’ป๐Ÿ”ฎ

๐Ÿ“ฆ What is a Package?

A package is like a neatly wrapped gift box ๐ŸŽ that contains all the necessary files, code, and instructions for a software application to work smoothly on your Linux system. ๐ŸŽˆ It's like a little software package ready to be delivered to your computer doorstep! ๐Ÿšš๐Ÿ’จ

๐Ÿ’ผ Different Kinds of Package Managers:

Linux has several package managers, each with its unique style and preferences! Let's look at two popular ones:

  1. ๐Ÿงถ Debian Package Manager (dpkg) & Advanced Package Tool (APT): APT is like a dynamic duo, working together to manage packages like superheroes! ๐Ÿฆธโ€โ™‚๏ธ๐Ÿฆธโ€โ™€๏ธ They are the dynamic duo found in Debian-based distributions like Ubuntu, Linux Mint, and more. With APT, you can easily install, update, and remove software. Just type a simple command, and it'll handle the rest! ๐Ÿ‘พ

  2. ๐Ÿ Python Package Manager (pip): If you're a Python developer ๐Ÿ, you'll love pip! It's like a personal assistant ๐Ÿงž for Python packages. Whenever you need to add a new Python library or update an existing one, pip will make it happen in a snap! ๐Ÿ’ซ

  3. ๐Ÿ“ฆ Red Hat Package Manager (RPM): RPM is another handy package manager used in Red Hat-based distributions like Fedora, CentOS, and others. It's like a trusty delivery service ๐Ÿšš, efficiently managing software packages on your system. RPM makes sure everything is in its place and runs smoothly! ๐Ÿงฐ

  4. ๐ŸŽ Snapcraft: Snapcraft brings the gift of universal packages! ๐ŸŽ It's like a Swiss Army Knife ๐Ÿ‡จ๐Ÿ‡ญ of package managers, working across various Linux distributions. Snap packages come with all the dependencies they need, making software installation a breeze! ๐ŸŒฌ๏ธ๐Ÿ’จ

Remember, each Linux distribution may have its unique package manager, but they all share the same goal: to make software management a piece of cake! ๐Ÿฐ

๐Ÿง๐Ÿ“ฆ How to Install Docker and Jenkins on Ubuntu using Package Managers! ๐Ÿš€

Are you ready to supercharge your Ubuntu system with Docker and Jenkins? ๐Ÿš€ In this guide, we'll walk you through the process of installing these powerful tools using package managers. Buckle up, and let's get started! ๐ŸŒŸ

๐Ÿณ Installing Docker with APT:

Docker is like a magician for developers, allowing them to create, deploy, and run applications in containers. Let's use the APT package manager to install Docker on Ubuntu:

Step 1: Update Your Package List Open a terminal by pressing Ctrl + Alt + T, and let's update our package list to ensure we get the latest versions:

sudo apt update

Step 2: Install Docker Now, we can install Docker using the following command:

sudo apt install docker.io

Step 3: Verify Docker Installation To confirm that Docker is up and running, run this command:

docker --version

You should see the version number of Docker installed on your system. Congratulations! ๐ŸŽ‰ Docker is now ready to create and manage containers on your Ubuntu system.

๐Ÿ”ง Installing Jenkins with APT:

Jenkins is a fantastic automation tool, perfect for continuous integration and continuous deployment (CI/CD) pipelines. Let's use APT to install Jenkins on Ubuntu:

๐Ÿ“ Before We Begin: Before installing Jenkins, let's make sure we have Java installed on our system. Jenkins relies on Java to run, so it's essential to have Java set up first.

Step 0: Check Java Installation To check if Java is already installed, open your terminal and run:

java -version

If you see the version information, great! You already have Java installed, and you can proceed to install Jenkins. ๐ŸŽ‰ If not, no worriesโ€”we'll install it now.

Step 1: Install Java If you need to install Java, use the APT package manager to install OpenJDK, which is the most popular Java version for Linux systems:

sudo apt install openjdk-17-jre
java -version

Step 3: Install Jenkins It's time for Jenkins to shine! Use the APT package manager to install Jenkins:

 curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
   /usr/share/keyrings/jenkins-keyring.asc > /dev/null
 echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
   https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
   /etc/apt/sources.list.d/jenkins.list > /dev/null
 sudo apt-get update
 sudo apt-get install jenkins

๐Ÿ• Time to sit back and relax while Jenkins gets installed. โ˜•

Step 4: Start and Enable Jenkins Once Jenkins is installed, we need to start the service and make sure it automatically starts whenever you boot up your system:

sudo systemctl start jenkins
sudo systemctl enable jenkins

๐Ÿ”Œ Jenkins is now plugged in and ready to go!

Step 5: Unlock Jenkins and Set Up Now, let's access Jenkins through its web interface. Open your favorite web browser and enter this address: http://localhost:8080

๐Ÿ”‘ You'll be greeted with an admin password prompt. No worries, we've got you covered! To retrieve the password, run this command in the terminal:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the password and paste it into the Jenkins web page to unlock the magic of Jenkins! ๐Ÿง™โ€โ™‚๏ธ

Step 6: Jenkins Is All Yours! Follow the on-screen instructions to customize your Jenkins setup, choose your favorite plugins, and create your admin user. ๐Ÿ› ๏ธ

๐ŸŽ‰ Congratulations! You now have Jenkins up and running on your system! ๐ŸŽ‰

๐Ÿš€ Time to Explore Jenkins's Power Jenkins is your ultimate automation hero ๐Ÿฆธโ€โ™‚๏ธ๐Ÿฆธโ€โ™€๏ธ, helping you build, test, and deploy your projects effortlessly. With Jenkins pipelines, you can automate complex tasks and focus on what matters mostโ€”your code! ๐Ÿ’ป๐Ÿ”

Task 1: Check Docker Status First things first! Let's check if Docker is up and running on your system. Open your terminal and enter this command:

sudo systemctl status docker

You should see a detailed status report of the Docker service. If it shows "active" and "running," congrats! Docker is good to go. ๐ŸŽ‰ If not, make sure you completed the Docker installation correctly before proceeding. ๐Ÿณ๐Ÿ’ป

Task 2: Stopping Jenkins Service Now, let's get our hands on Jenkins! We'll stop the Jenkins service and see the difference before and after with screenshots. ๐Ÿ“ธ

Before:

Jenkins Service Running

To stop the Jenkins service, run this command:

sudo systemctl stop jenkins

After:

Jenkins Service Stopped

Awesome! Jenkins is now stopped, and you can see the change in the status. ๐Ÿ›‘โœจ

Task 3: Understanding systemctl vs. service You might have noticed that we used "systemctl" to manage Docker and Jenkins services. But wait, what about "service"? Let's find out! ๐Ÿค”

"systemctl" and "service" are both used to control services on your system. However, "systemctl" is more modern and flexible, while "service" is a legacy command. ๐Ÿ›๏ธ

  • "systemctl": Used in systemd-based systems (like Ubuntu 16.04 and newer). It provides more advanced control and additional features.

  • "service": Used in older sysvinit-based systems. It's simpler but doesn't offer all the functionalities of "systemctl."

In our tasks, we opted for "systemctl" because it's widely supported and recommended for newer systems. ๐ŸŒŸ

๐ŸŽ‰ Congratulations! You've successfully completed our tasks! ๐Ÿ†๐Ÿš€ By now, you should feel more confident with Docker, Jenkins, and managing services using "systemctl." It's time to embrace the power of automation and continuous integration with Jenkins! ๐Ÿค–๐Ÿ’ป

Keep exploring, learning, and creating wonders in the tech world! ๐ŸŒˆ Happy coding! ๐ŸŽˆ๐ŸŽ‰

ย