Friday, June 12, 2026

How to check the httpd service is running on multiple hosts using bash and Ansible


# FOR loop — to check the httpd service is running or not
for server in web01 web02 web03; do
  echo "Checking $server..."
  ssh "$server" "systemctl status httpd"
done


ansible-playbook check_httpd_status.yml -i inventory.ini


name: Check HTTPD service status on multiple servers
hosts: webservers
become: yes
gather_facts: no

tasks:

name: Get HTTPD service status
ansible.builtin.systemd:
name: httpd
register: httpd_status
name: Display HTTPD status
ansible.builtin.debug:
msg: |
Host: {{ inventory_hostname }}
Service State: {{ httpd_status.status.ActiveState }}
Sub State: {{ httpd_status.status.SubState }}

Monday, June 8, 2026

Linux Host 2FA Configuration Guide

 Two-Factor Authentication (2FA) on a Linux host is commonly configured using Google Authenticator PAM.


1. Install Google Authenticator
RHEL/Rocky/Oracle Linux:
sudo dnf install google-authenticator qrencode -y

Older systems:
sudo yum install google-authenticator qrencode -y

2. Configure OTP for a User
google-authenticator

Recommended answers:
- Time-based tokens: y
- Update .google_authenticator file: y
- Disallow multiple uses: y
- Increase time skew: n
- Enable rate limiting: y

3. Configure PAM
Edit /etc/pam.d/sshd and add:
auth required pam_google_authenticator.so

4. Configure SSH
Edit /etc/ssh/sshd_config and set:
ChallengeResponseAuthentication yes
UsePAM yes
PasswordAuthentication yes

For newer OpenSSH:
KbdInteractiveAuthentication yes
UsePAM yes

5. Restart SSH
sudo systemctl restart sshd

6. Test Login
ssh user@server-ip

You should be prompted for:
- Password
- Verification code (OTP)

Verify Logs:
RHEL:
sudo tail -f /var/log/secure

Ubuntu:
sudo tail -f /var/log/auth.log

Rollback:
Remove:
auth required pam_google_authenticator.so
from /etc/pam.d/sshd and restart sshd.

Kubernetes Cluster Commands

kubectl cluster-info kubectl get nodes -o wide Kubernetes Pod Commands kubectl get pods kubectl get pods -o wide kubectl get pods -l

Sunday, May 31, 2026

Networking core concepts

L1 – Physical: Cables, NICs, bits. L2 – Data Link: MAC addresses, switches, VLANs, STP. L3 – Network: IP, routing, subnets, CIDR, ARP. L4 – Transport: TCP/UDP, ports, handshake, retransmission. L5 – Session: Connection management. Rare in practical ops. L6 – Presentation: Encryption, compression, TLS framing. L7 – Application: HTTP, DNS, SMTP, gRPC.

How to Install KVM Packages

egrep -c '(vmx|svm)' /proc/cpuinfo lsmod | grep kvm virt-host-validate Install KVM Packages on Rhel/Centos sudo dnf install -y qemu-kvm libvirt virt-install virt-manager Install KVM Packages Ubuntu sudo apt update sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients virtinst Manage Libvirt Service systemctl status libvirtd;systemctl start libvirtd;systemctl enable libvirtd;systemctl restart libvirtd List Virtual Machines virsh list virsh list --all virsh start vmname ( To start the VM) virsh shutdown vmname ( To shutdown VM) virsh destroy vmname ( To Desntroy the VM) =======> Do not use this command virsh reboot vmname ( To reboot the VM) virsh suspend vmname ( To Suspend VM) virsh resume vmname ( To Resume VM) virsh dominfo vmname ( VM iminfo) virsh dumpxml vmname virsh domstats vmname (To Show CPU and memory usage) virsh domuuid vmname (To Get VM UUID) virsh snapshot-list vmname Create Virtual Machines Using ISO virt-install \ --name rhel9 \ --memory 4096 \ --vcpus 2 \ --disk size=50 \ --cdrom /iso/rhel9.iso \ --os-variant rhel9.0 \ --network bridge=br0 virsh snapshot-create-as vmname snapshot1 virsh snapshot-revert vmname snapshot1 virsh snapshot-delete vmname snapshot1 virsh net-list --all virsh net-start default virsh net-autostart default Storage Commands virsh pool-list --all virsh vol-list default virsh pool-info default Console Access virsh console vmname Ctrl + ] virsh migrate --live vmname qemu+ssh://destination-host/system virsh setmem vmname 8G --live virsh setvcpus vmname 4 --live journalctl -u libvirtd virsh domiflist vmname Daily KVM Administration Commands virsh list --all virsh dominfo vmname virsh start vmname virsh shutdown vmname virsh reboot vmname virsh console vmname virsh domifaddr vmname virsh snapshot-list vmname virsh net-list --all virsh pool-list --all

Thursday, May 28, 2026

LVM Basics

PV (Physical Volume) – Physical disks/partitions VG (Volume Group) – Pool of storage LV (Logical Volume) – Logical partitions created from the pool pvs # List PVs vgs # List VGs lvs # List LVs pvcreate /dev/sdb vgcreate vg_data /dev/sdb lvcreate -L 10G -n lv_app vg_data mkfs.xfs /dev/vg_data/lv_app mount /dev/vg_data/lv_app /app lvextend -L +5G /dev/vg_data/lv_app xfs_growfs /app vgextend vg_data /dev/sdc lvremove /dev/vg_data/lv_app vgremove vg_data pvremove /dev/sdb # Add new disk pvcreate /dev/sdb # Add disk to VG vgextend vg_root /dev/sdb # Extend LV lvextend -l +100%FREE /dev/vg_root/lv_data # Grow filesystem xfs_growfs /data # XFS resize2fs /dev/vg_root/lv_data # EXT4

Wednesday, May 20, 2026

Access mode and Trunk mode.


FeatureAccess ModeTrunk Mode

VLANs carried
One VLANMultiple VLANs
VLAN TaggingNoYes
Used forEnd devicesNetwork devices
Traffic typeUntaggedTagged

Tuesday, May 19, 2026

Common Linux System Calls


 
CategoryExamplesPurpose

File Operationsopen(), read(), write(), close()File handling
Process Controlfork(), exec(), wait()Process creation
Memory Managementmmap(), brk()Memory allocation
Device Managementioctl()Device communication
Networkingsocket(), bind(), connect()Network operations
Informationgetpid(), uname()System information

What is the Kernel?

User Space Where normal programs run (bash, nginx, bash, curl, docker python) Kernel Space Where the kernel runs with full hardware Scheduler, memory manager access syscalls API through which programs request open(), read(), fork() kernel services