Skip to main content

Command Palette

Search for a command to run...

Day 28 of #90DaysOfDevOps – Revision Day: Strengthening the Foundation

Updated
5 min read
Day 28 of #90DaysOfDevOps – Revision Day: Strengthening the Foundation

Why DevOps?

DevOps is a culture and set of practices that combines Development and Operations to deliver software faster and more reliably.

DevOps Lifecycle

Plan → Develop → Build → Test → Release → Deploy → Operate → Monitor

Benefits

  • Faster deployments

  • Better collaboration

  • Automation

  • Reduced failures

  • Continuous improvement


Linux Fundamentals

Linux File System Hierarchy

/
├── bin     → Essential commands
├── boot    → Boot files
├── dev     → Device files
├── etc     → Configuration files
├── home    → User directories
├── lib     → Libraries
├── opt     → Optional software
├── proc    → Process information
├── root    → Root user home
├── tmp     → Temporary files
├── usr     → User programs
└── var     → Logs and variable data

Important Commands

pwd          # Current directory
ls -la       # List all files
cd           # Change directory
mkdir dir    # Create directory
rm -rf dir   # Delete directory
cp file1 file2
mv old new

Process Management

A process is a running program.

View Processes

ps aux
top
htop

Kill Process

kill PID
kill -9 PID

Find Process Using Port

sudo lsof -i :8080

ss -tulpn | grep 8080

Systemd Services

Manage background services.

Check Status

systemctl status nginx

Start Service

systemctl start nginx

Stop Service

systemctl stop nginx

Enable on Boot

systemctl enable nginx

User Management

Create user:

sudo useradd devops

Set password:

sudo passwd devops

Create group:

sudo groupadd developers

Add user to group:

sudo usermod -aG developers devops

Permissions

Numeric Permissions

r = 4
w = 2
x = 1

Example:

chmod 755 script.sh

Meaning:

Owner  = rwx = 7
Group  = r-x = 5
Others = r-x = 5

Ownership

chown user file.txt

chgrp group file.txt

Networking

Check Connectivity

ping google.com

DNS Lookup

dig google.com

nslookup google.com

Show Listening Ports

ss -tulpn

Get Public IP

curl ifconfig.me

Common Ports

22  → SSH
80  → HTTP
443 → HTTPS
3306 → MySQL
5432 → PostgreSQL
6379 → Redis

LVM (Logical Volume Management)

Steps

  1. Create Physical Volume
pvcreate /dev/sdb
  1. Create Volume Group
vgcreate vg_data /dev/sdb
  1. Create Logical Volume
lvcreate -L 5G -n lv_data vg_data
  1. Format
mkfs.ext4 /dev/vg_data/lv_data
  1. Mount
mount /dev/vg_data/lv_data /mnt/data

Why LVM?

  • Resize storage without repartitioning

  • Combine multiple disks

  • Easier storage management


Shell Scripting

Variables

NAME="Tushar"

echo $NAME

User Input

read NAME

echo $NAME

Arguments

echo $1
echo $2
echo $#
echo $@

Conditions

if [ "$age" -gt 18 ]
then
  echo "Adult"
fi

File Check

if [ -f "$filepath" ]
then
   echo "File exists"
fi

Loops

For Loop

for i in {1..10}
do
  echo $i
done

While Loop

while read line
do
  echo $line
done < file.txt

Functions

greet() {
 echo "Hello $1"
}

greet Tushar

Strict Mode

set -euo pipefail

Meaning

-e → Exit on error
-u → Error on undefined variable
pipefail → Catch pipe failures

Crontab

Open

crontab -e

Every Day at 3 AM

0 3 * * * /path/script.sh

Every 5 Minutes

*/5 * * * * /path/script.sh

Git Fundamentals

Initialize Repo

git init

Check Status

git status

Stage Changes

git add .

Commit

git commit -m "message"

History

git log --oneline

Branching

Create Branch

git switch -c feature-login

Switch Branch

git switch main

Merge

git merge feature-login

Rebase

Before:

A-B-C
   \
    D-E

After:

A-B-C-D-E
git rebase main

Stash

Save Work

git stash

List

git stash list

Restore

git stash pop

Reset vs Revert

Reset

git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1

Revert

git revert COMMIT_ID

Difference:

Reset  → Rewrites history
Revert → Creates new undo commit

GitHub CLI

Login

gh auth login

Check Status

gh auth status

Create Repo

gh repo create

Create PR

gh pr create

List PRs

gh pr list

Create Issue

gh issue create

Most Important Commands to Remember

ls -la
pwd
top
df -h
free -h
chmod 755
chown
ping
dig
ss -tulpn
git status
git add .
git commit
git push
git pull
git merge
git rebase
git stash
gh auth login
gh pr create

Areas to Improve

  • LVM Advanced Concepts

  • DNS & Subnetting

  • Git Rebase

  • GitHub Actions

  • AWS (Upcoming)