Exploring Linux Shells, Commands, and DevOps Tools – Day 6 of #100DaysOfCode
Introduction:
Welcome to Day 6 of my #100DaysOfCode journey! Today, I dived deep into Linux shell types, basic commands, and the role of DevOps tools at various stages of development. Linux commands form the backbone of many DevOps processes, so mastering them is crucial for streamlining workflows and ensuring seamless deployment. Let's break down what I learned!
DevOps Tools at Various Stages:
Understanding which DevOps tool to use at different stages of the Software Development Life Cycle (SDLC) is key to efficient automation and deployment. Here’s a quick overview:
Planning & Version Control:
Git: Version control for tracking changes and collaborating on code.
Jira: Task management and issue tracking.
CI/CD (Continuous Integration/Continuous Delivery):
- Jenkins, GitLab CI: Automate build, test, and deployment pipelines.
Configuration Management:
- Ansible, Chef, Puppet: Automating infrastructure and managing configurations across environments.
Containerization & Orchestration:
- Docker, Kubernetes: Packaging applications in containers for easy scaling and deployment.
Monitoring & Logging:
- Prometheus, Grafana: Real-time monitoring of application and system health.
Linux Shell Types:
In Linux, different shell types provide different levels of interaction with the operating system. Here’s a breakdown of the shells I explored today:
Bourne Shell (sh):
A widely-used, simple shell designed for portability.C Shell (csh):
Adds C-like syntax and better scripting capabilities.Z Shell (zsh):
Known for features like better autocompletion and customization.Bourne Again Shell (bash):
The most popular shell, used widely in Linux and macOS.
Linux Command Basics:
Mastering basic Linux commands is crucial for working efficiently in terminal environments. Here are a few fundamental commands I covered:
echo: Prints text to the screen.
ls: Lists directory contents.
cd: Changes the directory.
pwd: Prints the working directory path.
mkdir: Creates a directory.
Directory and File Commands:
mkdir -p: Creates nested directories.
rm -r: Recursively removes a directory.
cp -r: Copies files and directories.
Text Editors: vi Editor:
Working with text files in the terminal is an essential skill. I explored the vi editor today:
Command Mode: Navigates through the text, copies (yy), and deletes (dd) lines.
Insert Mode: Allows editing text.
Last Line Mode: Saves changes, exits the editor, or performs other commands.
Other Essential Linux Commands:
whoami: Displays the current user.
id: Shows user identity and group details.
su: Switches user accounts.
sudo: Executes commands with superuser privileges.
curl and wget: Used for downloading files from the internet.
Package Management:
Understanding package managers helps in installing and managing software in Linux. Here are two I explored:
RPM: Red Hat Package Manager.
YUM: A higher-level package manager that resolves dependencies.
Managing Services in Linux:
I also learned how to manage services using the systemctl command. Here’s how to start, stop, and check the status of services:
systemctl start <service_name>
systemctl stop <service_name>
systemctl status <service_name>
systemctl enable <service_name> # Enable at startup
systemctl disable <service_name> # Disable from startup
Configuring a Program as a Service:
To configure a program as a service in Linux, follow these steps:
Create a service file in
/etc/systemd/system/with the.serviceextension.Add configuration details such as the path to the executable and environment settings.
Use
systemctl enableto ensure it starts on boot.Manage the service using
systemctl start/stop/statuscommands.
Here’s a simple example of a service file for a custom Python application:
[Unit]
Description=My Python App Service
[Service]
ExecStart=/usr/bin/python3 /path/to/app.py
Restart=always
User=nobody
[Install]
WantedBy=multi-user.target
Conclusion:
Today's learning covered the essentials of Linux shells, commands, and how to manage services. These skills are foundational for working in a DevOps environment, where automation and efficient system management are crucial. Stay tuned as I explore more advanced topics in my #100DaysOfCode journey!