$ root_n_reels
Main site
ROOT_N_REELS / REFERENCE LIBRARY

Linux Administration
Complete Practical Guide

Detailed, original learning material covering 28 core Linux administration areas, with explanations, operational guidance, and command references.

28 chaptersCommands & examplesBeginner → AdvancedEnterprise Linux focus
Lab safety: Validate commands on a disposable lab system first. Storage, firewall, account, mail, and package commands can cause service disruption or data loss.
Reading progress0%
CHAPTER 01

CentOS / Enterprise Linux Overview

Understand the Linux operating-system model, enterprise distributions, repositories, support lifecycle, and administrator responsibilities.

Linux is a Unix-like operating system built around the kernel, user-space utilities, filesystems, services, and applications. Enterprise distributions such as CentOS Stream, RHEL, Rocky Linux, and AlmaLinux share many administration concepts, but package versions, support policies, repositories, and security tooling can differ.

Linux architecture

  • Kernel: CPU scheduling, memory management, device drivers, networking, and system calls.
  • Init/service manager: systemd commonly manages boot, services, targets, dependencies, and cgroups.
  • User space: shells, libraries, utilities, daemons, and applications.
  • Package ecosystem: RPM packages and repository metadata provide repeatable software installation.
  • Configuration and logs: commonly stored under /etc, /var/log, and systemd journal storage.

Administrator responsibilities

  • Availability, capacity, patching, monitoring, backups, security, change control, and incident response.
  • Document changes and preserve evidence during troubleshooting.
  • Prefer least privilege, automation, and tested rollback procedures.

Essential discovery commands

cat /etc/os-releaseIdentify distribution and release information.
uname -rShow the running kernel release.
hostnamectlDisplay hostname and operating-system details.
lscpuReview CPU architecture and topology.
lsblk -fReview block devices and filesystems.
timedatectlInspect time, timezone, and synchronization state.
CHAPTER 02

Basic Linux Commands and Text Processing

Master the shell, pipelines, redirection, navigation, and the filtering utilities used daily by administrators.

The Linux command line follows a composable-tool approach: one command produces data and another filters, transforms, counts, or stores it. This is particularly useful for logs, inventory, audits, and operational reports.

Shell fundamentals

  • pwd shows the current directory.
  • cd changes location; cd - returns to the previous directory.
  • command --help provides quick usage information.
  • man command provides authoritative local documentation.

Redirection and pipelines

  • > overwrites a file; >> appends.
  • 2> redirects standard error.
  • &> redirects standard output and error in Bash.
  • | connects standard output to another command.
  • tee displays output and writes it simultaneously.

Common text utilities

grep -i 'failed' /var/log/secureSearch case-insensitively for failed events.
less +G /var/log/messagesOpen a file at the end for review.
tail -F /var/log/messagesFollow a log through rotation.
head -n 20 file.txtDisplay the first 20 lines.
wc -l file.txtCount lines.
sort -k3,3n report.txtSort numerically by the third field.
uniq -cCount adjacent duplicate lines; sort first when needed.
cut -d: -f1 /etc/passwdExtract usernames from the passwd file.
sed -n '1,20p' file.txtPrint a selected line range.
tr '[:lower:]' '[:upper:]'Convert lowercase input to uppercase.
paste file1 file2Combine files line by line.
CHAPTER 03

vi / Vim Text Editor

Edit configuration files efficiently and safely with modes, navigation, search, replacement, and recovery.

Vim operates primarily in Normal mode and Insert mode. Press Esc whenever you are unsure which mode is active.

Safe editing workflow

  1. Back up critical configuration before editing.
  2. Open the file and inspect existing content.
  3. Make the smallest required change.
  4. Save, validate syntax, and test the affected service.
  5. Record the change and rollback method.

Useful commands

vim /etc/ssh/sshd_configOpen a configuration file.
i / a / oInsert before cursor, after cursor, or on a new line.
gg / GJump to the beginning or end.
/patternSearch forward.
n / NMove to next or previous match.
:%s/old/new/gReplace all matches.
:set numberShow line numbers.
:w !sudo tee % >/dev/nullSave a file when opened without sufficient privileges, where appropriate.
:q!Exit without saving.
CHAPTER 04

File and Folder Management

Manage paths, files, directories, links, metadata, permissions, and safe cleanup.

Linux treats many resources as filesystem objects. Understand the difference between a file’s content, metadata, inode, pathname, and open file descriptor.

Important concepts

  • Absolute path: starts from /.
  • Relative path: interpreted from the current directory.
  • Hard link: another directory entry for the same inode.
  • Symbolic link: a path reference that can cross filesystems.
  • inode: metadata structure containing ownership, permissions, timestamps, and block references.

Permissions

For files, read means viewing, write means modifying, and execute means running. For directories, read permits listing, write permits creating/deleting entries, and execute permits traversal.

mkdir -p /opt/app/{bin,conf,logs}Create nested directories.
cp -a source destinationCopy recursively while preserving attributes where possible.
mv old newRename or move an object.
ln -s /opt/app/current /opt/app/liveCreate a symbolic link.
stat fileDisplay detailed metadata.
find /var -xdev -type f -size +1GFind large files without crossing filesystems.
rm --interactive=always fileRequest confirmation before deletion.
chmod 640 configSet owner read/write and group read permissions.
chown app:app configChange owner and group.
CHAPTER 05

User and Group Management

Create and govern local accounts, groups, shells, password aging, and administrative access.

Account management should follow identity governance: each person receives a unique account, access is granted through groups, privileged actions are auditable, and inactive accounts are disabled.

Key files

  • /etc/passwd: account identity and shell fields.
  • /etc/shadow: password hashes and aging data.
  • /etc/group: group membership.
  • /etc/sudoers and included files: controlled privilege delegation.

Operational guidance

  • Do not share root credentials.
  • Use visudo to validate sudo policy.
  • Review UID/GID consistency in centrally managed environments.
  • Use non-login shells for service accounts when interactive access is unnecessary.
useradd -m -s /bin/bash aliceCreate a user and home directory.
passwd aliceSet or change a password.
groupadd appopsCreate a group.
usermod -aG appops aliceAdd supplementary group membership.
id aliceDisplay identity and groups.
chage -l aliceReview password aging.
getent passwd aliceQuery configured identity sources.
visudoSafely edit sudo policy.
CHAPTER 06

Quota Management

Control per-user or per-group disk consumption and prevent a single account from exhausting shared storage.

Quotas are useful on multi-user filesystems, shared application areas, hosting platforms, and environments where uncontrolled growth can affect availability.

Quota concepts

  • Soft limit: threshold that may allow a grace period.
  • Hard limit: maximum permitted usage.
  • Block quota: controls space consumption.
  • Inode quota: controls the number of filesystem objects.

Quota support and commands vary by filesystem and distribution. Plan maintenance windows and verify support before enabling quotas on production filesystems.

mount | grep ' /home 'Confirm the target filesystem and mount options.
quotacheck -cum /homeCreate or update quota accounting files where supported.
quotaon /homeEnable quotas on the filesystem.
repquota /homeReport quota usage.
edquota -u aliceEdit a user’s quota limits.
quota -u aliceDisplay a user’s current usage and limits.
CHAPTER 07

systemd Services: Start, Stop, and Boot

Manage service units, startup behavior, dependencies, targets, and service failures.

systemd uses unit files to describe services, sockets, mounts, timers, targets, and other resources. Separate runtime state from boot-time enablement: starting a service now does not necessarily enable it at boot.

Service lifecycle

  • start activates a service now.
  • stop stops it now.
  • restart stops and starts it.
  • reload asks the service to reread configuration without a full restart.
  • enable configures activation during boot.
  • mask prevents activation until unmasked.
systemctl status sshdInspect state and recent messages.
systemctl enable --now chronydEnable at boot and start immediately.
systemctl disable --now httpdDisable at boot and stop immediately.
systemctl reload httpdReload configuration when supported.
systemctl list-dependencies multi-user.targetInspect target dependencies.
systemctl list-units --failedList failed units.
systemctl cat sshdDisplay the unit definition and overrides.
systemctl daemon-reloadReload unit files after changes.
CHAPTER 08

Resource Management with systemd and cgroups

Understand service resource boundaries using systemd properties and control groups.

Control groups, or cgroups, organize processes hierarchically and apply resource accounting or limits. systemd creates and manages cgroups for services, sessions, slices, and scopes.

Useful resource controls

  • CPUQuota: limits CPU time available to a service.
  • MemoryMax: caps memory consumption.
  • TasksMax: limits the number of processes or tasks.
  • IOWeight: influences relative I/O priority where supported.

Apply limits gradually and monitor service behavior. A limit that is too low can cause instability or repeated restarts.

systemctl status app.serviceLocate the service’s cgroup and state.
systemctl show app.service -p MemoryCurrentRead current memory accounting when available.
systemctl set-property app.service MemoryMax=1GApply a runtime resource property.
systemctl edit app.serviceCreate a persistent drop-in override.
systemd-cgtopView resource use by control group.
CHAPTER 09

Process and Job Management

Inspect, prioritize, signal, and troubleshoot processes and shell jobs.

A process has a PID, parent PID, credentials, open files, environment, scheduling attributes, and resource usage. Diagnose before terminating: identify the command, owner, dependencies, and impact.

Signals

  • SIGTERM requests graceful shutdown.
  • SIGKILL cannot be caught and should be a last resort.
  • SIGHUP is often used to request configuration reload, depending on the daemon.
ps -eo pid,ppid,user,%cpu,%mem,stat,cmd --sort=-%cpuProcess inventory sorted by CPU.
pstree -apShow parent-child process relationships.
topInteractive process view.
kill -TERM 1234Request graceful termination.
pkill -u aliceSignal processes owned by a user; use carefully.
free -hReview memory and swap.
nice -n 10 commandStart with a lower CPU scheduling priority.
renice 10 -p 1234Change priority of an existing process.
jobs -l; fg %1Inspect and foreground shell jobs.
CHAPTER 10

Firewall Setup

Configure host-based firewall policy and verify allowed services without weakening security.

A firewall should implement the minimum network exposure required by the workload. Document the intended source networks, destination ports, protocol, owner, and expiration or review date.

firewalld concepts

  • Zone: trust level associated with interfaces or sources.
  • Service: predefined group of ports and protocols.
  • Runtime configuration: active immediately but may not survive reboot.
  • Permanent configuration: saved policy applied after reload or restart.
firewall-cmd --get-active-zonesShow active zones.
firewall-cmd --list-allInspect a zone’s current configuration.
firewall-cmd --permanent --add-service=httpsAdd HTTPS persistently.
firewall-cmd --reloadApply permanent configuration.
firewall-cmd --query-port=8443/tcpCheck whether a port is allowed.
nft list rulesetInspect nftables rules where applicable.
CHAPTER 11

PHP and Application Runtime Setup

Understand how web servers, PHP runtimes, databases, permissions, and logs fit together.

A PHP deployment commonly includes Apache or Nginx, PHP packages or PHP-FPM, a database, TLS certificates, application files, and log collection. Keep runtime configuration separate from application code and avoid exposing diagnostic output publicly.

Validation checklist

  • Confirm supported PHP version and required extensions.
  • Use a dedicated service account where appropriate.
  • Restrict configuration and secret-file permissions.
  • Disable verbose errors in production responses.
  • Test the application through the same path used by clients.
php -vDisplay PHP version.
php -mList loaded extensions.
php --iniShow configuration file locations.
systemctl status php-fpmCheck PHP-FPM where used.
curl -I http://localhostValidate HTTP response headers.
CHAPTER 12

Python on Enterprise Linux

Install, isolate, run, and maintain Python applications without destabilizing system tooling.

Do not replace the distribution’s system Python blindly. Enterprise utilities may depend on a vendor-supported interpreter. Prefer virtual environments, application-specific paths, modules, or containers for independent workloads.
  1. Install a supported Python runtime.
  2. Create a virtual environment.
  3. Pin dependencies in a requirements file.
  4. Run the application with a dedicated account.
  5. Use systemd, a container, or another supervisor.
  6. Log errors and define a health check.
python3 --versionCheck interpreter version.
python3 -m venv .venvCreate a virtual environment.
source .venv/bin/activateActivate the environment.
python -m pip install -r requirements.txtInstall pinned dependencies.
python -m pip freezeRecord installed package versions.
python -m compileall app/Perform a basic syntax compilation check.
CHAPTER 13

Ruby on Enterprise Linux

Prepare Ruby development or application environments using supported packages and isolated version management.

Ruby applications may require a specific interpreter, Bundler version, native libraries, and environment variables. For development, a version manager can isolate projects; for production, standardize the runtime and deployment artifact.

Operational concerns

  • Match Ruby and Bundler versions to the application lockfile.
  • Compile native gems only with approved build dependencies.
  • Keep secrets outside source control.
  • Use a process manager and monitor memory and restart behavior.
ruby -vShow Ruby version.
gem envDisplay RubyGems environment.
bundle installInstall dependencies from the lockfile.
bundle exec ruby app.rbRun with the project dependency context.
gem listList installed gems.
CHAPTER 14

Perl Administration

Use Perl for text processing, system automation, and legacy operational tooling.

Perl remains common in older enterprise automation and monitoring environments. When maintaining Perl scripts, document interpreter requirements, modules, input assumptions, exit codes, and security-sensitive operations.

Good scripting practices

  • Use strict and warnings.
  • Validate input and quote shell arguments carefully.
  • Prefer Perl modules over fragile shell interpolation.
  • Log failures and return meaningful exit codes.
perl -vDisplay interpreter version.
perl -c script.plCheck syntax without running the script.
perl -MModule -e 'print $Module::VERSION'Check a module version.
perldoc -f openRead documentation for a Perl function.
CHAPTER 15

OpenLDAP Installation and Configuration

Understand LDAP directory concepts, server configuration, client lookup, and secure authentication.

LDAP is a directory protocol used for identity and configuration data. Important concepts include entries, attributes, object classes, distinguished names, the directory information tree, binds, search bases, and access controls.

Design considerations

  • Define naming contexts and schema before deployment.
  • Use strong administrator and service-account credentials.
  • Restrict anonymous reads and write access.
  • Use TLS for credentials and directory data in transit.
  • Back up directory data and test restoration.
ldapsearch -x -H ldap://server -b 'dc=example,dc=com'Perform a basic search where permitted.
ldapwhoami -x -H ldap://serverTest bind identity.
getent passwd user1Test NSS directory resolution.
systemctl status slapdInspect the LDAP service.
openssl s_client -connect ldap.example.com:636Inspect LDAPS certificate negotiation.
CHAPTER 16

SSL/TLS Certificates with OpenSSL

Create, inspect, deploy, and renew certificates while protecting private keys.

TLS provides encryption, server authentication, and integrity for network communication. A deployment normally contains a private key, leaf certificate, intermediate chain, service configuration, and renewal process.

Certificate checklist

  • Confirm subject alternative names match the hostname.
  • Check validity dates and issuer chain.
  • Protect private keys with restrictive permissions.
  • Test from a client perspective after deployment.
  • Automate renewal and reload services safely.
openssl x509 -in cert.pem -noout -subject -issuer -datesInspect certificate identity and validity.
openssl x509 -in cert.pem -noout -textDisplay certificate details.
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csrCreate a private key and CSR.
openssl s_client -connect example.com:443 -servername example.comInspect a remote TLS handshake.
chmod 600 server.keyRestrict private-key access.
CHAPTER 17

Apache Web Server

Install, configure, validate, secure, and troubleshoot Apache HTTP Server.

Apache commonly serves static content, reverse proxies applications, terminates TLS, and writes access and error logs. Configuration is modular, and exact paths vary by distribution.

Deployment checklist

  • Define the listening address and ports.
  • Configure virtual hosts and document roots.
  • Disable directory listing unless required.
  • Set ownership and permissions for web content.
  • Enable TLS and security headers where appropriate.
  • Validate configuration before reload.
dnf install httpdInstall Apache on DNF-based systems.
apachectl -tValidate configuration syntax.
systemctl enable --now httpdEnable and start Apache.
curl -I http://localhostTest HTTP response.
journalctl -u httpd -bReview service logs.
ss -lntp | grep ':80'Confirm the listening socket.
CHAPTER 18

MySQL / MariaDB Setup

Deploy a database service with secure initialization, access controls, backups, and monitoring.

MySQL and MariaDB are relational database systems. Treat database deployment as an application dependency: define storage requirements, authentication, backup strategy, recovery objectives, connection limits, and patching procedures.

Security essentials

  • Do not expose database ports broadly to untrusted networks.
  • Use separate application accounts with minimum privileges.
  • Protect backups because they contain sensitive data.
  • Monitor slow queries, storage, connections, and replication where applicable.
dnf install mariadb-serverInstall MariaDB packages where supported.
systemctl enable --now mariadbStart and enable the database service.
mysql_secure_installationPerform interactive hardening where available.
mysqladmin pingCheck responsiveness.
ss -lntp | grep ':3306'Inspect the database listener.
mysqldump --single-transaction dbname > db.sqlCreate a logical backup for suitable workloads.
CHAPTER 19

Postfix and IMAP/POP3 with Dovecot

Understand mail transfer, mailbox access, DNS dependencies, TLS, and operational controls.

Mail systems combine multiple components: Postfix commonly handles SMTP transport, while Dovecot provides IMAP and POP3 access. DNS records, reverse DNS, authentication, TLS, spam controls, queue monitoring, and reputation all affect deliverability.

Operational safeguards

  • Do not operate an open relay.
  • Use authenticated submission for clients.
  • Require TLS where appropriate.
  • Monitor queue growth and deferred mail.
  • Configure SPF, DKIM, and DMARC according to organizational requirements.
postconf -nDisplay non-default Postfix configuration.
postqueue -pList queued messages.
postsuper -d QUEUEIDDelete a specific queued message only after validation.
systemctl status postfixCheck SMTP service.
doveconf -nDisplay effective Dovecot configuration.
journalctl -u postfix -u dovecotReview mail-service events.
CHAPTER 20

Anonymous FTP and File Transfer

Understand legacy FTP behavior, risks, and safer alternatives for file exchange.

Traditional FTP transmits control and data connections separately and does not provide encryption by itself. Anonymous FTP should be considered legacy and used only when explicitly required, isolated, and protected by policy.

Safer design

  • Prefer SFTP over SSH or HTTPS-based transfer.
  • If anonymous access is required, restrict it to a dedicated directory.
  • Prevent uploads from becoming executable content.
  • Monitor disk usage and access logs.
  • Do not expose sensitive data through public download paths.
ss -lntp | grep ':21'Check for an FTP control listener.
find /srv/ftp -type f -lsReview published files.
sftp user@serverUse encrypted file transfer.
sha256sum file.isoVerify transferred file integrity.
CHAPTER 21

Remote Management: SSH, VNC, and X11

Administer remote systems securely and understand encrypted tunnels and graphical access.

SSH is the preferred remote administration protocol for Linux servers. Use unique accounts, key-based authentication, access restrictions, logging, and controlled privilege escalation.

SSH hardening

  • Disable direct root login where policy permits.
  • Restrict allowed users or groups.
  • Use strong keys and protect private keys.
  • Limit forwarding features when unnecessary.
  • Monitor authentication logs and failed attempts.

VNC and X11 forwarding may be useful for specific graphical tasks, but they increase complexity and should be protected through SSH tunnels or private networks.

ssh admin@serverConnect to a remote host.
ssh -i ~/.ssh/id_ed25519 admin@serverUse a specific identity file.
ssh -L 8443:internal-web:443 bastionCreate a local port-forwarding tunnel.
scp file admin@server:/tmp/Copy a file securely.
sftp admin@serverTransfer files interactively.
ssh -G serverDisplay effective client configuration.
CHAPTER 22

Traffic Monitoring

Measure network throughput, errors, sockets, routes, and interface behavior.

Traffic monitoring should distinguish bandwidth utilization from packet loss, errors, retransmissions, latency, and application response time. Capture a baseline before diagnosing abnormal behavior.

Investigation sequence

  1. Check interface link and address state.
  2. Review routes and default gateway.
  3. Inspect socket listeners and connection counts.
  4. Check interface errors and drops.
  5. Test DNS and destination ports.
  6. Correlate network data with application and system logs.
ip -s linkReview interface counters.
ip routeDisplay routing table.
ss -sShow socket summary.
ss -lntupList listening sockets and processes.
nloadView live interface traffic where installed.
sar -n DEV 1 5Sample network statistics.
ethtool eth0Inspect link characteristics.
CHAPTER 23

Log Management and journalctl

Collect, filter, preserve, rotate, and interpret system and application logs.

Logs are evidence. Establish a timeline, preserve relevant entries, correlate multiple sources, and avoid deleting or modifying evidence during an incident.

Useful journal filters

  • Boot: current or previous boot.
  • Unit: one service.
  • Priority: errors and above.
  • Time: a defined investigation window.
  • Identifier: kernel, sshd, sudo, or another component.
timedatectl set-timezone Asia/KolkataSet timezone when approved.
journalctl -bShow current-boot messages.
journalctl -b -1Show previous-boot messages.
journalctl -p err..alertShow high-priority events.
journalctl -u sshd --since '1 hour ago'Filter service events by time.
journalctl --disk-usageReview journal storage.
dmesg -TReview kernel messages with readable timestamps.
CHAPTER 24

Backup and Recovery

Design reliable file-level, block-level, archive, encryption, and restoration workflows.

Backups must be planned around recovery point objective, recovery time objective, retention, off-host copies, encryption, immutability where required, and regular restore testing.

Backup patterns

  • File-level: selective restoration and efficient synchronization.
  • Block-level: image-based recovery for compatible disks and systems.
  • Archive: portable bundles for long-term storage.
  • Application-aware: consistent database or application state.

Never treat a successful backup job as proof of recoverability until restoration has been tested.

rsync -aHAX --numeric-ids source/ backup/Synchronize files and preserve attributes where supported.
rsync -av --dry-run source/ backup/Preview synchronization changes.
tar -czf etc-backup.tar.gz /etcCreate a compressed archive.
tar -tzf etc-backup.tar.gzInspect archive contents.
sha256sum backup.tar.gzCreate an integrity checksum.
dd if=/dev/sda of=disk.img bs=4M status=progressCreate a block image only with verified device paths and downtime planning.
gpg --symmetric archive.tar.gzEncrypt an archive with a protected passphrase.
CHAPTER 25

System Updates and Patch Management

Plan, test, apply, verify, and document operating-system updates.

Patching is a lifecycle process: inventory, risk assessment, testing, approval, deployment, validation, and rollback or remediation. Kernel updates may require reboot planning; application updates may require service restarts.

Patch workflow

  1. Review advisories and affected systems.
  2. Confirm backups and rollback options.
  3. Test in a representative environment.
  4. Apply updates during an approved window.
  5. Validate services, monitoring, and application health.
  6. Record versions and evidence.
dnf check-updateCheck for available updates.
dnf updateinfo list updatesReview advisory information where available.
dnf historyReview package transactions.
dnf history info IDInspect a specific transaction.
dnf updateApply updates after approval.
needs-restarting -rCheck whether a reboot may be required where available.
uname -rVerify running kernel after reboot.
CHAPTER 26

Bash Shell Scripting

Create safe, maintainable automation with variables, input/output, conditions, loops, functions, and diagnostics.

Bash is effective for orchestration of existing command-line tools. Use Python or another language when data structures, error handling, portability, or API integration become complex.

Script quality principles

  • Quote variables unless word splitting is intended.
  • Validate arguments and required commands.
  • Use meaningful exit codes.
  • Log actions and errors.
  • Use temporary files safely.
  • Test with non-production data first.

Core constructs

#!/usr/bin/env bashUse an explicit interpreter declaration.
set -Eeuo pipefailEnable stricter Bash error behavior; test carefully.
if [[ -f "$file" ]]; then ... fiConditional file test.
for host in "${hosts[@]}"; do ... doneIterate safely over an array.
while IFS= read -r line; do ... done < fileRead lines without trimming whitespace.
trap cleanup EXITRegister cleanup logic.
((count++))Perform arithmetic.
command -v ssh >/dev/null || exit 1Validate a required command.
CHAPTER 27

Package Management with YUM / DNF / RPM

Search, install, update, verify, query, and remove packages using RPM-based tooling.

RPM is the package format and database; YUM and DNF resolve dependencies and interact with repositories. Prefer supported repositories and verify package origin before installation.

Common tasks

  • Search by name or description.
  • Inspect package metadata and files.
  • Install or remove packages with dependency resolution.
  • Review transaction history.
  • Verify installed files where appropriate.
dnf repolistList enabled repositories.
dnf search keywordSearch package metadata.
dnf info packageDisplay package information.
dnf install packageInstall a package.
dnf remove packageRemove a package after dependency review.
dnf clean allClean cached repository data.
rpm -qa | sortList installed RPMs.
rpm -qf /usr/bin/vimFind the package owning a file.
rpm -V packageVerify installed package files.
CHAPTER 28

Volume and Logical Volume Management

Manage disks, partitions, physical volumes, volume groups, logical volumes, filesystems, and expansion.

LVM separates physical storage from logical allocation. A typical design is disk or partition → physical volume → volume group → logical volume → filesystem → mount point.

Planning rules

  • Confirm the correct device using serials, WWNs, and lsblk.
  • Understand filesystem growth and shrink limitations.
  • Back up data before storage changes.
  • Use persistent UUIDs or stable device identifiers in /etc/fstab.
  • Monitor free space in both the volume group and filesystem.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTSInventory storage.
fdisk -lReview partition information.
pvcreate /dev/sdbInitialize a physical volume.
vgcreate vgdata /dev/sdbCreate a volume group.
lvcreate -L 20G -n lvapp vgdataCreate a logical volume.
pvs; vgs; lvsReview LVM state.
mkfs.xfs /dev/vgdata/lvappCreate an XFS filesystem.
mount /dev/vgdata/lvapp /dataMount a filesystem.
lvextend -r -L +5G /dev/vgdata/lvappExtend LV and filesystem where supported.
findmnt /dataVerify mount details.