Unit IV - Linux Server Administration and Virtualization
Unit IV - Linux Server Administration and Virtualization
What is RHEL?
Red Hat Enterprise Linux (RHEL) is a commercial Linux distribution developed by Red Hat Inc., primarily
used in enterprise environments.
• Stable, secure, and certified for use in critical environments like banks, data centers, government
systems.
• Subscription-based support: Includes access to Red Hat customer support, certified software, and
updates.
• Lifecycle Support: Each major release gets long-term support (up to 10 years).
What is CentOS?
CentOS (Community Enterprise Operating System) was a free, open-source version of RHEL, built from
RHEL source code.
• Red Hat shifted CentOS to CentOS Stream, which is now a rolling-release version of RHEL.
• CentOS Stream is ahead of RHEL (acts like a pre-release), not recommended for production use.
# Check OS version
cat /etc/redhat-release
# Update packages
# Install Apache
The boot process in Linux is the sequence of steps the system follows from powering on the hardware to
loading the operating system kernel and reaching a usable shell or GUI.
Step Description
1. BIOS / UEFI Firmware runs POST (Power-On Self Test) and initializes hardware.
2. Bootloader (GRUB2) Loads the boot menu and OS kernel into memory.
3. Kernel The Linux kernel initializes core hardware and mounts the root filesystem.
4. init / systemd PID 1 process starts system services (targets/runlevels).
5. Login A login prompt (CLI or GUI) appears.
File/Folder Description
/boot/grub2/grub.cfg Main GRUB2 configuration file (auto-generated).
/etc/default/grub GRUB settings file (editable).
/etc/grub.d/ Scripts to build the GRUB config.
/boot/ Holds the kernel (vmlinuz), initramfs, and GRUB files.
Common GRUB2 Commands
sudo vi /etc/default/grub
sudo grub2-set-default 0
3. Filesystem Hierarchy
The Linux Filesystem Hierarchy Standard (FHS) defines the directory structure and their contents in Unix-
like operating systems.
Directory Purpose
/ Root directory – the top of the hierarchy.
/bin Essential user binaries (e.g., ls, cp, mv).
/sbin System binaries (e.g., reboot, ifconfig).
/etc Configuration files.
/dev Device files (e.g., /dev/sda, /dev/null).
/proc Virtual filesystem for process and kernel info.
/sys Contains system hardware info (also virtual).
/var Variable data like logs, mail, and spool files.
/tmp Temporary files (cleared on reboot).
/home User home directories (e.g., /home/john).
/root Home directory of root user.
/lib, /lib64 Shared libraries needed by binaries in /bin and /sbin.
Directory Purpose
/usr Secondary hierarchy for user applications.
/opt Optional or third-party software.
/mnt, /media Mount points for external storage devices.
/boot Files needed for booting (kernel, GRUB, initrd).
ls /
ls /var/log
cat /proc/cpuinfo
cat /sys/class/net/eth0/address
cat /etc/passwd
df -h
mount
The Linux hierarchy is mountable, meaning new devices/filesystems can be mounted anywhere in the tree.
4. Shell Environment
What is a Shell?
• A Shell is a program that interprets user commands and sends them to the operating system kernel.
• Common shells:
Types of Shells
Shell Description
Login Shell Starts when user logs in (e.g., via console, SSH).
Shell Description
Non-login Shell Launched in an already logged-in session (e.g., terminal inside GUI).
Interactive Shell Takes input from user.
Non-interactive Shell Runs scripts automatically.
Environment Variables
• Environment variables store system-wide values used by the shell and applications.
Variable Meaning
HOME User's home directory.
USER Current logged-in user.
PATH Directories to search for executables.
PS1 Prompt style (e.g., \u@\h:\w\$).
SHELL Default shell for the user.
Example Commands
echo $HOME
echo $PATH
export MYNAME="Boopalan"
echo $MYNAME
Aliases
Functions
myfunc() {
myfunc Boopalan
5. Text Editors
A text editor is a program used to create and modify plain text files, such as:
• Shell scripts
• Configuration files
• Source code
• Log files
Linux administrators use terminal-based editors most of the time (especially on headless servers).
Using nano
nano filename.txt
• Edit file
• Ctrl + O: Save
• Ctrl + X: Exit
• Ctrl + W: Search
Using vim
vim filename.conf
• :w: Save
• :q: Quit
Vim Modes
Mode Description
Normal Mode For navigation, commands (default mode)
Insert Mode For editing text (i to enter)
Visual Mode For selecting text
Command Mode For commands like :wq, :q!
Task:
Create a file called greet.sh, add a simple echo script using vim, then save and run it:
chmod +x greet.sh
./greet.sh
• Users are assigned permissions and access via user IDs (UIDs) and groups.
Understanding Users
• Home directory
• Shell
whoami
id
Task Command
Create user sudo useradd username
Set password sudo passwd username
Modify user sudo usermod -aG groupname username
Delete user sudo userdel -r username
View user info cat /etc/passwd
Change shell sudo chsh -s /bin/bash username
Understanding Groups
View groups:
groups
cat /etc/group
Task Command
Create group sudo groupadd developers
Add user to group sudo usermod -aG developers username
Delete group sudo groupdel developers
List all groups getent group
Changes apply on next login or after running newgrp.
• Linux is a multi-user OS, so controlling who can access, modify, or execute files is essential for
security and privacy.
• Owner
• Group
Permissions are:
• r → Read
• w → Write
• x → Execute
Example:
Symbol Meaning
- Regular file (d = directory, l = symlink)
rwx Owner permissions
r-x Group permissions
r-- Others' permissions
Octal (Numeric) Permissions
Task Command
Change permissions chmod 755 file.txt
Change ownership chown user:group file.txt
View permissions ls -l file.txt
ACLs provide fine-grained access control beyond the standard owner/group/other model.
Useful when:
ACL Commands
Task Command
Enable ACL on filesystem Mounted with acl option (most distros default to it)
View ACL getfacl file.txt
Set ACL setfacl -m u:alice:rwx file.txt
Remove ACL setfacl -x u:alice file.txt
Default ACL (for dirs) setfacl -d -m u:bob:rwX project/
ACL Example
getfacl notes.txt
Create a file project.txt, set rw- permissions for the owner, and give read-only access to another user using
ACL.
Overview
Linux software is managed in packages. RHEL and CentOS use the RPM Package Manager (RPM) system
along with YUM (or DNF) for handling dependencies and updates.
Task Command
Install package sudo rpm -ivh package.rpm
Upgrade package sudo rpm -Uvh package.rpm
Remove package sudo rpm -e package-name
Query installed packages rpm -qa
Check file ownership rpm -qf /path/to/file
Use RPM only when YUM is not available or for manual installs.
Replaced by DNF in newer RHEL versions (RHEL 8+), but YUM commands are still supported as symlinks.
Task Command
Install a package sudo yum install httpd
Remove a package sudo yum remove httpd
Update all packages sudo yum update
List installed packages yum list installed
Search for a package yum search nginx
Task Command
Get package info yum info git
3. Dependency Management
4. Software Repositories
[base]
name=Base OS
baseurl=http://mirror.centos.org/centos/$releasever/os/x86_64/
enabled=1
gpgcheck=1
5. Patching
What is Patching?
• Security vulnerabilities
• Bugs
• Performance issues
Task Command
Update a specific package sudo yum update bash
View available updates yum check-update
List installed kernel versions rpm -q kernel
Task Command
Apply security updates (RHEL) yum update --security
9. System Logging
System logging is the process of recording events and system activity (e.g., errors, warnings, service
messages) to help:
• Monitor performance
• Debug issues
Task Command
View a log file cat /var/log/messages
Scrollable view less /var/log/secure
Follow live log tail -f /var/log/messages
Filter by keyword grep ssh /var/log/secure
Print kernel logs `dmesg
Task Command
View all logs journalctl
View boot logs journalctl -b
Task Command
Filter by service journalctl -u sshd
View logs for a time range journalctl --since "2025-08-01"
Follow live logs journalctl -f
journalctl reads binary logs from /run/log/journal/ or /var/log/journal/
• Configured via:
1. Snapshots
What is a Snapshot?
• Fast, lightweight
lvremove /dev/vg0/my_snap
3. Restore
# Create backup
# Restore backup
11. Hypervisors
What is a Hypervisor?
A hypervisor (also called a Virtual Machine Monitor - VMM) is software or firmware that allows you to run
multiple virtual machines (VMs) on a single physical machine (host).
Each VM has its own OS, virtual CPU, memory, storage, and network interface, isolated from others.
Types of Hypervisors
Popular Hypervisors
Type 1:
• VMware ESXi – Industry-standard hypervisor with advanced features like vMotion, HA, DRS.
Type 2:
Security Note
• These are the two most widely used enterprise virtualization platforms.
• Both support virtual machine management, networking, storage, and high availability.
• Critical for roles in IT infrastructure, system admin, DevOps, cloud, and data center operations.
1. Microsoft Hyper-V
Overview:
Key Features:
• Checkpoint/Snapshots
Host Windows and Linux virtual servers for development or testing on a Windows Server machine.
What is vSphere?
Access via:
✅ VMware vSphere is preferred for large-scale enterprise setups with multiple physical hosts.
✅ Hyper-V is ideal for Windows shops and smaller/mid-size IT infrastructures.
Security Note
• Both support role-based access, VM encryption, network isolation, and snapshots for rollback.
Key VM Components:
Component Description
vCPU Virtual CPU allocated to the VM
vRAM Virtual memory for OS and applications
Virtual Disk A virtual hard drive (e.g., .vmdk, .vhdx)
NIC Network Interface Card
ISO Image Bootable OS installer (e.g., Ubuntu ISO)
VM Setup (Typical Steps)
• Select OS type/version
2. VM Networking Options
Hyper-V Networking
3. VM Storage Configuration
Storage Options:
• Local storage – Direct on ESXi/Hyper-V host.
• VMFS (VMware File System) – Optimized for virtual disks on shared storage.
Example Scenario
• Attach CentOS-Stream.iso
1. HA – High Availability
What is HA?
High Availability (HA) ensures automatic VM restart on another host if the original host fails.
How It Works:
• If a host fails:
Key Points:
What is DRS?
DRS automatically balances VM workloads across hosts in a cluster based on CPU and memory utilization.
How It Works:
Benefits:
What is vMotion?
vMotion allows live migration of a running VM from one ESXi host to another without downtime.
How It Works:
Use Cases:
Summary Table
Example Scenario
You have a 3-host ESXi cluster running 20 VMs. One host suddenly fails.
✅ HA restarts affected VMs on remaining hosts.
✅ DRS balances load by migrating some VMs to avoid overloading.
✅ vMotion ensures these migrations happen with no downtime.
1. Templates
What is a VM Template?
A template is a golden image of a virtual machine used to rapidly deploy new, identical VMs.
Key Features:
How to Use:
Use Case:
Deploy 50 identical Linux VMs for a training lab in minutes using a pre-built template.
2. Resource Pools
A logical container that allocates and isolates CPU and memory resources for a group of VMs.
Key Features:
o CPU
o RAM
Example:
Use Case:
Ensure production VMs always get guaranteed resources, even when load spikes.
What is a dvSwitch?
A Distributed Virtual Switch is a centralized network configuration that spans multiple ESXi hosts,
managed by vCenter.
Key Features:
• Ensures consistent network settings (VLAN, NIC teaming) across all hosts.
Use Case:
In a 10-host cluster, use dvSwitch for uniform networking, simplifying VM migration via vMotion.
Summary Table