Linux Administration
Complete Practical Guide
Detailed, original learning material covering 28 core Linux administration areas, with explanations, operational guidance, and command references.
CentOS / Enterprise Linux Overview
Understand the Linux operating-system model, enterprise distributions, repositories, support lifecycle, and administrator responsibilities.
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.Basic Linux Commands and Text Processing
Master the shell, pipelines, redirection, navigation, and the filtering utilities used daily by administrators.
Shell fundamentals
pwdshows the current directory.cdchanges location;cd -returns to the previous directory.command --helpprovides quick usage information.man commandprovides 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.teedisplays 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.vi / Vim Text Editor
Edit configuration files efficiently and safely with modes, navigation, search, replacement, and recovery.
Esc whenever you are unsure which mode is active.
Safe editing workflow
- Back up critical configuration before editing.
- Open the file and inspect existing content.
- Make the smallest required change.
- Save, validate syntax, and test the affected service.
- 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.File and Folder Management
Manage paths, files, directories, links, metadata, permissions, and safe cleanup.
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.User and Group Management
Create and govern local accounts, groups, shells, password aging, and administrative access.
Key files
/etc/passwd: account identity and shell fields./etc/shadow: password hashes and aging data./etc/group: group membership./etc/sudoersand included files: controlled privilege delegation.
Operational guidance
- Do not share root credentials.
- Use
visudoto 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.Quota Management
Control per-user or per-group disk consumption and prevent a single account from exhausting shared storage.
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.systemd Services: Start, Stop, and Boot
Manage service units, startup behavior, dependencies, targets, and service failures.
Service lifecycle
startactivates a service now.stopstops it now.restartstops and starts it.reloadasks the service to reread configuration without a full restart.enableconfigures activation during boot.maskprevents 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.Resource Management with systemd and cgroups
Understand service resource boundaries using systemd properties and control groups.
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.Process and Job Management
Inspect, prioritize, signal, and troubleshoot processes and shell jobs.
Signals
SIGTERMrequests graceful shutdown.SIGKILLcannot be caught and should be a last resort.SIGHUPis 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.Firewall Setup
Configure host-based firewall policy and verify allowed services without weakening security.
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.PHP and Application Runtime Setup
Understand how web servers, PHP runtimes, databases, permissions, and logs fit together.
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.Python on Enterprise Linux
Install, isolate, run, and maintain Python applications without destabilizing system tooling.
Recommended application pattern
- Install a supported Python runtime.
- Create a virtual environment.
- Pin dependencies in a requirements file.
- Run the application with a dedicated account.
- Use systemd, a container, or another supervisor.
- 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.Ruby on Enterprise Linux
Prepare Ruby development or application environments using supported packages and isolated version management.
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.Perl Administration
Use Perl for text processing, system automation, and legacy operational tooling.
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.OpenLDAP Installation and Configuration
Understand LDAP directory concepts, server configuration, client lookup, and secure authentication.
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.SSL/TLS Certificates with OpenSSL
Create, inspect, deploy, and renew certificates while protecting private keys.
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.Apache Web Server
Install, configure, validate, secure, and troubleshoot Apache HTTP Server.
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.MySQL / MariaDB Setup
Deploy a database service with secure initialization, access controls, backups, and monitoring.
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.Postfix and IMAP/POP3 with Dovecot
Understand mail transfer, mailbox access, DNS dependencies, TLS, and operational controls.
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.Anonymous FTP and File Transfer
Understand legacy FTP behavior, risks, and safer alternatives for file exchange.
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.Remote Management: SSH, VNC, and X11
Administer remote systems securely and understand encrypted tunnels and graphical access.
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.Traffic Monitoring
Measure network throughput, errors, sockets, routes, and interface behavior.
Investigation sequence
- Check interface link and address state.
- Review routes and default gateway.
- Inspect socket listeners and connection counts.
- Check interface errors and drops.
- Test DNS and destination ports.
- 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.Log Management and journalctl
Collect, filter, preserve, rotate, and interpret system and application logs.
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.Backup and Recovery
Design reliable file-level, block-level, archive, encryption, and restoration workflows.
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.System Updates and Patch Management
Plan, test, apply, verify, and document operating-system updates.
Patch workflow
- Review advisories and affected systems.
- Confirm backups and rollback options.
- Test in a representative environment.
- Apply updates during an approved window.
- Validate services, monitoring, and application health.
- 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.Bash Shell Scripting
Create safe, maintainable automation with variables, input/output, conditions, loops, functions, and diagnostics.
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.Package Management with YUM / DNF / RPM
Search, install, update, verify, query, and remove packages using RPM-based tooling.
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.Volume and Logical Volume Management
Manage disks, partitions, physical volumes, volume groups, logical volumes, filesystems, and expansion.
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.