Thursday, May 14, 2026

PXE Boot Flow

Client PXE Boot

DHCP assigns IP

TFTP downloads pxelinux.0

PXE menu appears

Kernel + initrd loaded

Installer downloads packages via HTTP

How to setup Automated PXE Server Setup Script

.
#!/bin/bash

# ============================================================
# Automated PXE Server Setup
# Supported OS : RHEL / Rocky / AlmaLinux 8 & 9
# Author : ChatGPT
# ============================================================

set -e

# -----------------------------
# Variables
# -----------------------------

PXE_SERVER_IP="192.168.1.10"
SUBNET="192.168.1.0"
NETMASK="255.255.255.0"
RANGE_START="192.168.1.100"
RANGE_END="192.168.1.200"
GATEWAY="192.168.1.1"

OS_NAME="rhel9"
ISO_MOUNT="/mnt/rhel9"
HTTP_ROOT="/var/www/html/${OS_NAME}"

TFTP_ROOT="/var/lib/tftpboot"
PXE_CFG="${TFTP_ROOT}/pxelinux.cfg"

# -----------------------------
# Install Required Packages
# -----------------------------

echo "Installing required packages..."

dnf install -y \
dhcp-server \
tftp-server \
syslinux \
httpd \
xinetd \
wget \
firewalld

# -----------------------------
# Enable Services
# -----------------------------

systemctl enable --now firewalld
systemctl enable --now httpd
systemctl enable --now tftp.socket
systemctl enable --now dhcpd

# -----------------------------
# Configure Firewall
# -----------------------------

echo "Configuring firewall..."

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --permanent --add-service=tftp
firewall-cmd --reload

# -----------------------------
# Create TFTP Structure
# -----------------------------

echo "Creating PXE boot directories..."

mkdir -p ${PXE_CFG}
mkdir -p ${TFTP_ROOT}/images/${OS_NAME}

# -----------------------------
# Copy PXE Boot Files
# -----------------------------

echo "Copying PXE boot files..."

cp /usr/share/syslinux/pxelinux.0 ${TFTP_ROOT}/
cp /usr/share/syslinux/menu.c32 ${TFTP_ROOT}/
cp /usr/share/syslinux/libutil.c32 ${TFTP_ROOT}/
cp /usr/share/syslinux/libcom32.c32 ${TFTP_ROOT}/

# -----------------------------
# Mount ISO
# -----------------------------

echo "Mounting ISO..."

mkdir -p ${ISO_MOUNT}

echo "Please place RHEL ISO at /root/rhel9.iso"

mount -o loop /root/rhel9.iso ${ISO_MOUNT}

# -----------------------------
# Copy Installation Files
# -----------------------------

echo "Copying installation files..."

mkdir -p ${HTTP_ROOT}

cp -r ${ISO_MOUNT}/* ${HTTP_ROOT}/

# -----------------------------
# Copy Kernel and Initrd
# -----------------------------

echo "Copying kernel and initrd..."

cp ${ISO_MOUNT}/images/pxeboot/vmlinuz \
${TFTP_ROOT}/images/${OS_NAME}/

cp ${ISO_MOUNT}/images/pxeboot/initrd.img \
${TFTP_ROOT}/images/${OS_NAME}/

# -----------------------------
# Create PXE Menu
# -----------------------------

echo "Creating PXE menu..."

cat <<EOF > ${PXE_CFG}/default

DEFAULT menu.c32
PROMPT 0
TIMEOUT 100
ONTIMEOUT local

MENU TITLE Automated PXE Boot Menu

LABEL local
MENU LABEL Boot from Local Disk
LOCALBOOT 0

LABEL ${OS_NAME}
MENU LABEL Install RHEL 9
KERNEL images/${OS_NAME}/vmlinuz
APPEND initrd=images/${OS_NAME}/initrd.img \
ip=dhcp \
inst.repo=http://${PXE_SERVER_IP}/${OS_NAME}

LABEL rescue
MENU LABEL Rescue Installed System
KERNEL images/${OS_NAME}/vmlinuz
APPEND initrd=images/${OS_NAME}/initrd.img rescue

EOF

# -----------------------------
# Configure DHCP
# -----------------------------

echo "Creating DHCP configuration..."

cat <<EOF > /etc/dhcp/dhcpd.conf

default-lease-time 600;
max-lease-time 7200;
authoritative;

allow booting;
allow bootp;

subnet ${SUBNET} netmask ${NETMASK} {

range ${RANGE_START} ${RANGE_END};

option routers ${GATEWAY};
option subnet-mask ${NETMASK};
option domain-name-servers 8.8.8.8;

next-server ${PXE_SERVER_IP};
filename "pxelinux.0";
}

EOF

# -----------------------------
# SELinux Adjustments
# -----------------------------

echo "Configuring SELinux..."

setsebool -P tftp_home_dir on

restorecon -Rv ${TFTP_ROOT}

# -----------------------------
# Restart Services
# -----------------------------

echo "Restarting services..."

systemctl restart dhcpd
systemctl restart httpd
systemctl restart tftp.socket

# -----------------------------
# Display Status
# -----------------------------

echo
echo "========================================"
echo " PXE SERVER SETUP COMPLETED"
echo "========================================"
echo
echo "PXE Server IP : ${PXE_SERVER_IP}"
echo "HTTP Repo : http://${PXE_SERVER_IP}/${OS_NAME}"
echo "TFTP Root : ${TFTP_ROOT}"
echo
echo "Boot target systems using PXE network boot."
echo

Sunday, May 3, 2026

Linux Interview Que.

1. What is Linux?

Answer:
Linux is an open-source, Unix-like operating system based on the Linux kernel. It manages hardware resources and provides services for applications.

🔹 2. Explain Linux boot process

Answer:

BIOS/UEFI initializes hardware
Bootloader (GRUB) loads kernel
Kernel initializes system
init / systemd starts services
System reaches target (multi-user/graphical)

🔹 3. What is the difference between hard link and soft link?

Answer:

Hard link: Points to same inode, survives file deletion
Soft link (symlink): Points to file path, breaks if original file is deleted

🔹 4. What is a process?

Answer:
A process is a running instance of a program with its own memory space and PID.

🔹 5. How do you check CPU and memory usage?

Answer:

CPU: top, htop, mpstat
Memory: free -m, vmstat

🔹 6. Difference between df and du?

Answer:

df: Shows filesystem disk usage
du: Shows directory/file usage

🔹 7. What is swap memory?

Answer:
Swap is disk space used as virtual memory when RAM is full.

🔹 8. What is /etc/fstab?

Answer:
A configuration file that defines filesystems to mount at boot time.

🔹 9. How do you find large files?

Answer:

find / -type f -size +500M
🔹 10. What is SSH?

Answer:
SSH (Secure Shell) is a secure protocol for remote login and command execution.

🔹 11. How do you secure SSH?

Answer:

Disable root login
Use key-based authentication
Change default port
Use firewall rules
🔹 12. What is cron?

Answer:
Cron is a job scheduler to run tasks automatically at scheduled times.

🔹 13. What is LVM?

Answer:
LVM (Logical Volume Manager) allows flexible disk management, resizing partitions without downtime.

🔹 14. What is RAID?

Answer:
RAID is data storage virtualization combining multiple disks for redundancy/performance.

RAID 0 → performance
RAID 1 → mirroring
RAID 5 → parity
🔹 15. How do you check open ports?

Answer:

ss -tuln
🔹 16. How do you check running processes?

Answer:

ps -ef
top
🔹 17. Server is slow — how do you troubleshoot?

Answer (structured approach):

Check CPU → top
Check memory → free -m
Check disk → df -h, iostat
Check logs → /var/log/messages
Check network → ss, netstat
🔹 18. Disk is full — what will you do?

Answer:

Check usage → df -h
Find large files → du -sh *
Clean logs → /var/log
Remove temp files → /tmp
Extend disk (LVM if available)
🔹 19. High CPU usage — how to identify?

Answer:

top
ps -eo pid,ppid,cmd,%cpu --sort=-%cpu
🔹 20. What is load average?

Answer:
Load average shows number of processes waiting for CPU.

Compare with CPU cores
Load > cores → system overloaded
🔹 21. Difference between process and thread?

Answer:

Process: Independent, own memory
Thread: Lightweight, shares memory
🔹 22. What are file permissions?

Answer:
Permissions control access:

Read (r), Write (w), Execute (x)
Owner, Group, Others
Example:
chmod 755 file
🔹 23. What is a zombie process?

Answer:
A zombie process is a completed process whose entry still exists in process table.

🔹 24. How do you monitor logs in real time?

Answer:

tail -f /var/log/syslog
🔹 25. What is systemd?

Answer:
Systemd is the init system and service manager in modern Linux.

Friday, May 1, 2026

what happens when Linux runs out of RAM and swap

  1. Page cache reclaim
  2. Swap out inactive pages
  3. OOM killer to terminate largest offender If swap=0 → OOM killer triggers earlier.

What is SELinux and how does it work?

Mandatory access control (MAC) enforcing rules on processes using labels. Policies restrict what a process can do even if it’s root. Modes: enforcingpermissivedisabled.

What is Cow “copy-on-write” in Linux.

When a process forks, parent and child share pages. Memory pages are only duplicated if one modifies them. Saves memory and speeds up process creation.

What is the role of /proc filesystem?

Pseudo-filesystem exposing kernel and process info:

  • /proc/cpuinfo
  • /proc/meminfo
  • /proc/<pid>/status Used for debugging and monitoring.

What is the difference between fork() and exec()?

fork() → creates a copy of the process exec() → replaces process memory with a new program Typically used together to spawn programs.

What is the difference between load average and CPU usage?

  • CPU usage = % CPU is busy
  • Load average = number of processes waiting for CPU or I/O High load average with low CPU = I/O bottleneck

What is a file descriptor?

An integer that refers to an open file, socket, or pipe. Standard ones:

  • 0 → stdin
  • 1 → stdout
  • 2 → stderr

What is cgroups and why is it used?

Control groups limit and control resource usage: CPU, memory, IO, pids, etc. Used by DockerKubernetes, systemd.

What are Linux namespaces?


Namespaces isolate system resources for containers:

  • pid – process IDs
  • net – network interfaces
  • mnt – mounts
  • ipc – message queues
  • uts – hostname
  • user – UID/GID mappings This provides container-level isolation.

How to Troubleshoot CPU,I/O,Memory,Network in Linux.

  • Debug high CPU → toppidstat -ustrace
  • Debug high I/O → iotopiostat
  • Debug memory leak → topsmempmap
  • Debug network → sstcpdumpcurl -v
  • DNS issues → dig/etc/resolv.conf
  • System slow → check: dmesgjournalctl, load average.

Sunday, April 26, 2026

How To set the sticky bit on a folder in Linux/Unix,

You typically use the chmod command.

chmod +

chmod 1777 <folder_name>


Thursday, April 23, 2026

What is SLI SLO SLA ?


- SLI (Service Level Indicator): This is the metric you're measuring. For a login service, it could be the ratio of successful login requests to total valid requests. It tells you how your service is performing right now. - SLO (Service Level Objective): You take that SLI and define a target around it. Something like "login availability should stay above 99.9% over a rolling 28-day window." When you're missing your SLO, it’s a signal to find out what's failing before customers notice. - SLA (Service Level Agreement): This is what you promise your customers in a contract. It's usually set lower than the SLO, say 99.5% monthly availability. If you breach it, you owe service credits.

What is the difference between a Pod, ReplicaSet, and Deployment?


In Kubernetes:

- Pod: The smallest deployable unit. It runs one or more containers that share networking and storage.

- ReplicaSet: Ensures a specified number of identical Pods are running at all times. It automatically creates or deletes Pods to maintain the replica count.

- Deployment: A higher-level object that manages ReplicaSets. It provides declarative updates, rolling deployments, and easy rollbacks.

In short:  
Pod = runs your app  
ReplicaSet = keeps the right number of Pods alive  
Deployment = handles updates and rollouts on top of ReplicaSet