LPIC-1 Module 2: Linux Installation and Package Management – A Complete Study Guide with Quiz & Commands
Published On: 6 July 2025
Objective
When it comes to mastering Linux system administration, whether you are aiming for certifications like LPIC-1 or RHCSA, or preparing for enterprise environments, understanding Linux installation and package management is fundamental. From laying out disk partitions to managing shared libraries, and from installing bootloaders to integrating systems with virtualization platforms, Linux gives administrators granular control. This guide explores essential concepts and commands related to Linux installation and package management, helping you build a solid foundation for real-world administration and certification success.
Topic 102.1: Design Hard Disk Layout
Designing a hard disk layout involves planning how your Linux system will organize and allocate its storage space across various partitions and filesystems. This process is crucial not only for optimal performance but also for ease of system administration, backups and future upgrades. Key considerations include separating system and user data, allocating swap space, and preparing the system for features like LVM or UEFI booting. A good layout ensures system stability and flexibility, especially in environments with varied workloads or user needs. The hard disk layout is the first and most crucial step before installing Linux. It determines how data is stored, how efficiently the system operates, and how easy it is to perform maintenance tasks such as backups and restores.
Key Concepts
- Separate Partitions: Separating directories like /, /var, /home, /boot, /tmp, and swap into individual partitions improves system management. For example, isolating /home ensures user files remain untouched during a system upgrade or reinstall, while separating /var helps prevent logs from consuming all root space. Isolating /tmp provides security benefits and prevents temporary files from filling up the root partition.
- LVM (Logical Volume Manager): LVM allows you to group physical volumes and create flexible logical volumes on top of them. You can resize, expand, or shrink logical volumes without repartitioning, making LVM ideal for dynamic environments. LVM provides snapshots for backups and the ability to span logical volumes across multiple physical disks.
- ESP (EFI System Partition): For systems using UEFI instead of BIOS, an ESP formatted with FAT32 is mandatory. It contains bootloaders and boot-related files required by the UEFI firmware to initialize the OS. The ESP is typically 512MB to 1GB in size.
- Swap Space: Acts as an overflow for RAM. When your system's physical memory is full, the kernel moves inactive pages in memory to swap space, preventing crashes and maintaining system responsiveness. Swap can exist as a dedicated partition or a file.
Swap Sizing Guidelines:
- Systems with ≤ 2GB RAM: 2x RAM size
- Systems with 2-8GB RAM: Equal to RAM size
- Systems with > 8GB RAM: At least 4GB, more if hibernation is needed
- For hibernation support: Swap should be at least equal to RAM size
Example Disk Layout
Mount Point | Filesystem | Size | Purpose |
---|---|---|---|
/ | ext4 | 20-50GB | Root filesystem |
/boot | ext4 | 1GB | Holds kernel and bootloader |
/home | ext4 | Varies | User files |
/var | ext4 | 10-20GB | Logs, spool files |
/tmp | ext4 | 5-10GB | Temporary files |
swap | swap | See guidelines | Virtual memory |
ESP | vfat | 512MB-1GB | UEFI boot partition |
MCQs
Q1. Which of the following mount points typically contains the Linux kernel and bootloader?
a) /home
b) /var
c) /boot
d) /root
Answer: c
Q2. What does LVM stand for in Linux?
a) Large Volume Manager
b) Logical Volume Manager
c) Linux Volume Machine
d) Layered Virtual Mapper
Answer: b
Q3. What is the recommended swap size for a system with 4GB of RAM?
a) 2GB
b) 4GB
c) 8GB
d) 1GB
Answer: b
Topic 102.2: Install a Boot Manager
A boot manager (or boot loader) is a crucial piece of software that is responsible for loading the Linux kernel into memory and starting the operating system after the system firmware (BIOS or UEFI) completes its checks. The most common boot manager in Linux systems is GRUB (GRand Unified Bootloader). It offers the flexibility to boot into multiple operating systems, select kernel versions, and troubleshoot boot-time issues.
There are two primary versions of GRUB:
- GRUB Legacy: Older systems may still use this version, which relies on files like menu.lst or grub.conf.
- GRUB 2: The modern default bootloader that uses grub.cfg and offers a modular architecture and dynamic configuration.
Why It is Important
- You can define alternative boot options, such as booting into a previous kernel or another OS
- In case the default boot entry fails, you can boot into a rescue or recovery environment
- You can customize boot parameters for kernel troubleshooting
- Essential for system recovery and maintenance
Where It is Installed
- On BIOS-based systems, GRUB is typically installed in the Master Boot Record (MBR) of the disk
- On UEFI systems, it's installed to the EFI System Partition (ESP), usually mounted at /boot/efi
Key GRUB Configuration Files
- /boot/grub/grub.cfg – Main configuration file (auto-generated) - Ubuntu/Debian path
- /boot/grub2/grub.cfg – Main configuration file (auto-generated) - RHEL/CentOS path
- /etc/default/grub – Defines default boot options
- /boot/efi/EFI/ – Contains EFI binaries for UEFI systems
- /etc/grub.d/ – Directory containing scripts that generate grub.cfg
Important Commands
# Install GRUB to the primary disk
sudo grub-install /dev/sda
# Regenerate GRUB configuration file (Ubuntu/Debian)
sudo grub-mkconfig -o /boot/grub/grub.cfg
# Regenerate GRUB configuration file (RHEL/CentOS)
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# Update GRUB (simplified command on Ubuntu)
sudo update-grub
Emergency GRUB Recovery
If GRUB fails to boot, you can use these emergency commands at the GRUB rescue prompt:
# List available partitions
grub rescue> ls
# Set root partition (example)
grub rescue> set root=(hd0,1)
# Load normal module
grub rescue> insmod normal
# Start normal boot
grub rescue> normal
Backup Boot Options
Configure multiple boot entries to boot into different kernel versions or OSes. GRUB automatically creates entries for:
- Current kernel version
- Previous kernel versions (for rollback)
- Recovery modes
- Memory test utilities
MCQs
Q1. Which command is used to install GRUB on a hard drive?
a) install-grub
b) grub-loader
c) grub-install
d) boot-manager
Answer: c
Q2. In GRUB 2, what file holds the generated configuration?
a) grub.conf
b) menu.lst
c) grub.cfg
d) grub.list
Answer: c
Q3. Which directory contains scripts that generate the GRUB configuration?
a) /boot/grub/
b) /etc/grub.d/
c) /etc/default/
d) /boot/efi/
Answer: b
Topic 102.3: Manage Shared Libraries
Shared libraries are dynamic libraries that multiple programs can use to perform common tasks, reducing redundancy and saving memory. Instead of each application including its own copy of a library, shared libraries are stored separately and linked at runtime. This modular approach to software design ensures efficient use of system resources and easier maintenance.
Key Concepts
1. Identify Shared Libraries
Use the ldd command to inspect a binary (e.g., an executable) and find out which shared libraries it depends on. For example:
ldd /usr/bin/ls
This will list the dynamic libraries the ls command relies on.
2. Typical Library Locations
Shared libraries are usually stored in:
- /lib - Essential system libraries
- /lib64 - 64-bit system libraries
- /usr/lib - User application libraries
- /usr/lib64 - 64-bit user libraries
- /usr/local/lib - Locally installed libraries
These locations are predefined and searched by the dynamic linker when executing programs.
3. Load Shared Libraries
When you run a program, the dynamic linker/loader (ld.so or ld-linux.so) checks which libraries the program needs and loads them into memory.
You can influence where it looks for libraries by using:
- LD_LIBRARY_PATH – a temporary environment variable for setting custom search paths
- /etc/ld.so.conf – permanent configuration listing additional library directories
- ldconfig – a tool that refreshes the system's library cache
Important Files and Utilities
ldd: Displays the shared libraries a binary requires. It is useful for verifying dependencies of executable files and troubleshooting missing library issues.
# Check dependencies of a binary
ldd /usr/bin/firefox
# Check if a binary is dynamically linked
ldd /bin/ls
ldconfig: Updates the dynamic linker run-time bindings. It scans the directories specified in /etc/ld.so.conf and creates the /etc/ld.so.cache file for faster library linking.
# Update library cache
sudo ldconfig
# Verbose output showing what's being cached
sudo ldconfig -v
# Print current cache contents
ldconfig -p
/etc/ld.so.conf: A system configuration file that contains a list of directories to search for shared libraries. It can also include other files from /etc/ld.so.conf.d/.
Example content:
include /etc/ld.so.conf.d/*.conf
/usr/local/lib
/opt/custom/lib
LD_LIBRARY_PATH: An environment variable that allows users to specify additional directories to be searched for shared libraries before the standard set of directories. This is often used for testing or running custom-built applications without installing libraries system-wide.
# Temporarily add a custom library path
export LD_LIBRARY_PATH=/home/user/custom/lib:$LD_LIBRARY_PATH
# Run application with custom library path
LD_LIBRARY_PATH=/opt/myapp/lib ./myapplication
Library Troubleshooting
Common library-related issues and solutions:
# Find which package provides a missing library (Debian/Ubuntu)
apt-file search libmissing.so
# Find which package provides a missing library (RHEL/CentOS)
yum whatprovides libmissing.so
# Verify library integrity
ldd -v /usr/bin/program
# Check for broken symlinks in library directories
find /usr/lib -type l -exec test ! -e {} \; -print
MCQs
Q1. Which command is used to list shared libraries used by a binary?
a) ldconfig
b) ldlist
c) ldd
d) listlib
Answer: c
Q2. Where is the library path configuration file located?
a) /etc/libs.conf
b) /etc/ld.so.conf
c) /usr/lib/ld.conf
d) /etc/libpath.conf
Answer: b
Q3. Which environment variable can be used to specify additional library search paths?
a) LIBRARY_PATH
b) LD_LIBRARY_PATH
c) LIB_PATH
d) SHARED_LIB_PATH
Answer: b
Topic 102.4: Use Debian Package Management
Debian-based systems, including Ubuntu and Linux Mint, use a package management system centered around .deb files and the Advanced Packaging Tool (APT). This system simplifies installing, updating, and removing software by resolving dependencies automatically and keeping packages up-to-date from trusted repositories.
Core Tools
dpkg A low-level package manager that installs, configures, removes, and provides information about .deb packages.
- It does not resolve dependencies, so it's mostly used for manually installing local .deb files
- Direct control over individual packages
apt / apt-get These are higher-level tools built on top of dpkg.
- They automatically handle dependencies, fetch software from configured repositories, and manage upgrades
- apt is a newer, user-friendly front end to apt-get with improved output formatting and is preferred for interactive use
- apt-get is still widely used in scripts and automation
apt-cache A command-line utility to search and show information about packages (name, description, version, dependencies).
- Useful when planning what to install or checking the status of a package in the repo
- Works with local package cache for fast searches
aptitude An interactive, text-based front end to APT.
- Offers menu-driven package management and is considered safer or more intuitive by some sysadmins
- Better at resolving complex dependency conflicts
Essential Commands
# Update package list from repositories
sudo apt update
# Install a package
sudo apt install nginx
# Remove a package (keep config files)
sudo apt remove nginx
# Remove package and config files
sudo apt purge nginx
# Upgrade all packages
sudo apt upgrade
# Upgrade with intelligent dependency handling
sudo apt full-upgrade
# Search for packages
apt search apache
# Show package information
apt show nginx
# List installed packages
apt list --installed
# Install local .deb file
sudo dpkg -i package.deb
# Fix broken dependencies after dpkg install
sudo apt install -f
# Reconfigure an installed package
sudo dpkg-reconfigure package-name
# Show package status
dpkg -l | grep nginx
# List files installed by a package
dpkg -L nginx
# Find which package owns a file
dpkg -S /usr/bin/nginx
Package Pinning and Preferences
APT allows you to control which version of a package should be installed using preferences:
# Create preferences file
sudo nano /etc/apt/preferences.d/nginx
# Example content to pin nginx to a specific version
Package: nginx
Pin: version 1.18.*
Pin-Priority: 1001
Essential Files
/etc/apt/sources.list This file contains a list of repository URLs where APT can fetch packages. Each line typically includes:
- The type of archive (e.g., deb for binary packages, deb-src for source packages)
- The URL of the repository
- The distribution name (e.g., focal, bullseye, stable)
- The components (e.g., main, universe, restricted)
Example entry:
deb http://archive.ubuntu.com/ubuntu focal main universe
deb http://security.ubuntu.com/ubuntu focal-security main universe
/etc/apt/sources.list.d/ This directory allows you to add additional repository configurations as separate .list files.
- Useful for adding third-party repositories without modifying the main sources.list file
- Each file should have a .list extension
- Example: adding Google Chrome's repo would involve creating google-chrome.list
/var/lib/dpkg/status This file tracks the status of all packages installed on the system.
- Used by dpkg to determine which packages are installed, removed, and their configuration state
- Contains detailed information about each package's current status
- Can be manually inspected to debug package management issues
Repository Management
# Add a new repository key
wget -qO - https://example.com/key.gpg | sudo apt-key add -
# Modern way to add repository keys
wget -qO - https://example.com/key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/example.gpg
# Add repository with key reference
echo "deb [signed-by=/usr/share/keyrings/example.gpg] https://repo.example.com stable main" | sudo tee /etc/apt/sources.list.d/example.list
MCQs
Q1. Which file lists the Debian package repositories?
a) /etc/dpkg.conf
b) /etc/deb.repos
c) /etc/apt/sources.list
d) /etc/apt/apt.conf
Answer: c
Q2. What is the command to reconfigure a Debian package?
a) dpkg-config
b) dpkg-reconfigure
c) dpkg-edit
d) apt-reconfigure
Answer: b
Q3. Which command is preferred for interactive package management in modern Debian systems?
a) apt-get
b) aptitude
c) apt
d) dpkg
Answer: c
Topic 102.5: Use RPM and YUM Package Management
RPM (Red Hat Package Manager) and YUM (Yellowdog Updater Modified) are two essential tools used for managing software on Red Hat-based distributions such as RHEL, CentOS, Fedora and Oracle Linux. RPM is a low-level package manager that installs, queries, verifies, updates, and removes individual .rpm files. However, it doesn't automatically resolve dependencies. That's where YUM (and its modern replacement, DNF) comes in. YUM is a high-level tool that works with repositories to handle dependency resolution, making software installation much easier and more reliable.
Important Note: In newer versions of RHEL (8+), Fedora (22+), and CentOS (8+), DNF has replaced YUM as the default package manager. However, YUM commands still work as DNF provides yum as an alias for backward compatibility.
What is RPM?
RPM stands for Red Hat Package Manager. It is a low-level tool used to install, query, verify, update, and remove .rpm packages manually.
Key Facts about RPM:
- It does not resolve dependencies automatically
- It is ideal for situations where you have local .rpm files or want to manage packages manually
- Provides detailed information about packages and files
Common rpm Commands:
# Install a package with verbose and hash output
sudo rpm -ivh package.rpm
# Upgrade or install a package
sudo rpm -Uvh package.rpm
# Remove a package
sudo rpm -e package-name
# List all installed packages
rpm -qa
# Find which package owns a file
rpm -qf /path/to/file
# Display detailed info about a package
rpm -qi package-name
# List files installed by a package
rpm -ql package-name
# Verify package integrity
rpm -V package-name
# Check package dependencies
rpm -qR package-name
# Import GPG key for package verification
sudo rpm --import /path/to/key.gpg
RPM Flags:
- -i: Install
- -v: Verbose (more detailed output)
- -h: Hash (shows progress bar)
- -q: Query
- -e: Erase (remove)
- -U: Upgrade
- -V: Verify
What is YUM/DNF?
YUM stands for Yellowdog Updater Modified. DNF (Dandified YUM) is its modern replacement that is more efficient and has better dependency resolution.
Why Use YUM/DNF?
- Automatically installs all required dependencies
- Works with repositories defined in configuration files
- Supports advanced operations like group installs, updates, and package version locks
- Better performance and memory usage (DNF)
Common yum/dnf Commands:
# Install Apache HTTP server
sudo yum install httpd
sudo dnf install httpd
# Uninstall Apache
sudo yum remove httpd
sudo dnf remove httpd
# Update all packages
sudo yum update
sudo dnf upgrade
# List all installed packages
yum list installed
dnf list installed
# Show information about a package
yum info httpd
dnf info httpd
# Search for packages related to 'ftp'
yum search ftp
dnf search ftp
# Install a group of packages
sudo yum groupinstall "Development Tools"
sudo dnf groupinstall "Development Tools"
# List available repositories
yum repolist
dnf repolist
# Clean package cache
sudo yum clean all
sudo dnf clean all
# Check for available updates
yum check-update
dnf check-update
# Install from local RPM file with dependencies
sudo yum localinstall package.rpm
sudo dnf localinstall package.rpm
SUSE Linux Package Management
SUSE Linux uses zypper as its package manager:
# Install a package
sudo zypper install nginx
# Remove a package
sudo zypper remove nginx
# Update all packages
sudo zypper update
# Search for packages
zypper search apache
# Add repository
sudo zypper addrepo http://repo.url repo-name
Important Configuration Files
File | Purpose |
---|---|
/etc/yum.conf | Global YUM configuration |
/etc/dnf/dnf.conf | Global DNF configuration |
/etc/yum.repos.d/*.repo | Repository definitions |
/var/cache/yum/ | Cache directory for YUM |
/var/cache/dnf/ | Cache directory for DNF |
Repository Management
You can add third-party or local repositories by placing .repo files in /etc/yum.repos.d/ or /etc/dnf/repos.d/.
Example repository file (/etc/yum.repos.d/epel.repo):
[epel]
name=Extra Packages for Enterprise Linux 8 - $basearch
baseurl=https://download.fedoraproject.org/pub/epel/8/Everything/$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Verify and Query with RPM
You can query details about packages, verify files, and more using RPM:
# Check if nginx is installed
rpm -qa | grep nginx
# Verify the integrity of nginx files
rpm -V nginx
# List files installed by httpd package
rpm -ql httpd
# Show package dependencies
rpm -qR httpd
# Show what packages require a specific package
rpm -q --whatrequires glibc
Package Groups
Both YUM and DNF support package groups for installing collections of related packages:
List available groups
yum grouplist
dnf grouplist
Install a group
sudo yum groupinstall "Web Server"
sudo dnf groupinstall "Web Server"
Remove a group
sudo yum groupremove "Web Server"
sudo dnf groupremove "Web Server"
MCQs
Q1. What command shows which RPM package owns a specific file?
a) rpm -q
b) rpm -f
c) rpm -qf
d) rpm -fi
Answer: c
Q2. Which is a package manager used on SUSE Linux systems?
a) yum
b) dnf
c) apt
d) zypper
Answer: d
Q3. What has replaced YUM in newer Red Hat-based distributions?
a) APT
b) DNF
c) Zypper
d) Portage
Answer: b
Topic 102.6: Linux as a Virtualization Guest
Linux systems are often deployed as virtual machines (VMs) or containers rather than on physical hardware. As a virtualization guest, Linux must operate effectively within a virtualized environment provided by platforms like VMware, KVM, Hyper-V, or public cloud services such as AWS, Azure, and Google Cloud Platform. Understanding how Linux behaves as a guest system is essential for DevOps, cloud engineers, and system administrators working in scalable, automated infrastructure deployments.
Concepts
Virtual Machines
Virtual machines are complete OS environments that operate on emulated hardware. Each VM includes its own kernel and system files, running independently of the host OS. Popular hypervisors include:
- VMware vSphere/ESXi - Enterprise virtualization platform
- KVM (Kernel-based Virtual Machine) - Linux-native hypervisor
- Microsoft Hyper-V - Windows-based hypervisor
- Oracle VirtualBox - Desktop virtualization
- Xen - Open-source hypervisor
Linux as a VM guest may require the use of guest additions or drivers to optimize integration with the host system.
Containers
Containers offer a more lightweight and efficient virtualization solution. Instead of emulating hardware and running a full OS, containers share the host kernel but maintain isolated user space environments. This makes containers faster and more portable, often used for microservices and DevOps workflows. Popular container technologies include:
- Docker - Most popular container platform
- Podman - Daemonless container engine
- LXC/LXD - System containers
- containerd - Container runtime
cloud-init
cloud-init is a widely used tool in cloud environments to automate the configuration of Linux VMs during boot. It supports setting up hostnames, SSH keys, users, and network settings based on metadata provided by the cloud provider. This helps deploy consistent and secure VM instances quickly.
System Image Templates
Templates are pre-configured VM images used for fast deployment. When cloning or templating Linux systems, it's important to reset unique system identifiers like the machine ID and SSH host keys to avoid security and networking conflicts. This ensures that each cloned instance behaves as an independent system.
Tools and Technologies
Guest Drivers and Additions
These are special drivers installed on a Linux virtual machine to enhance performance and integration with the host system:
- VirtIO drivers: Used with KVM/QEMU for optimized disk, network, and memory balloon operations
- VMware Tools: Provides better graphics, shared folders, time synchronization, and improved mouse/keyboard integration
- Hyper-V Integration Services: Enables features like dynamic memory, enhanced session mode, and time sync
- VirtualBox Guest Additions: Offers shared folders, seamless mouse integration, and display resolution adjustment
cloud-init Configuration
A tool commonly used in cloud environments to initialize virtual machines at first boot. It reads metadata provided by the cloud platform to configure:
- SSH keys and authorized users
- Hostname and network configuration
- Package installation and updates
- Custom scripts and commands
- File system resizing
Example cloud-init configuration (/etc/cloud/cloud.cfg):
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAA...
packages:
- nginx
- git
runcmd:
- systemctl enable nginx
- systemctl start nginx
System Images and Templates
These are pre-configured templates or snapshots of virtual machines or containers that enable quick deployment of identical systems in large-scale environments. Benefits include:
- Faster deployment times
- Consistent system configurations
- Reduced manual configuration errors
- Standardized security baselines
However, when cloning systems, unique identifiers must be reset to prevent conflicts.
Preparing Linux for Cloning/Templating
When creating templates or cloning Linux systems, certain unique identifiers must be reset to ensure each instance operates independently:
Machine ID Reset:
# Remove existing machine ID
sudo rm -f /etc/machine-id
sudo rm -f /var/lib/dbus/machine-id
# Generate new machine ID on next boot
sudo systemd-machine-id-setup
# Alternative: truncate the file (it will be regenerated)
sudo truncate -s 0 /etc/machine-id
SSH Host Keys Reset:
# Remove existing SSH host keys
sudo rm -f /etc/ssh/ssh_host_*
# Regenerate keys (Debian/Ubuntu)
sudo dpkg-reconfigure openssh-server
# Regenerate keys (RHEL/CentOS)
sudo ssh-keygen -A
Network Configuration Cleanup:
# Remove network interface persistence (older systems)
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
# Clear network manager connections (if using NetworkManager)
sudo rm -f /etc/NetworkManager/system-connections/*
# Reset network interface names (for systemd-networkd)
sudo rm -f /etc/systemd/network/99-default.link
Log Cleanup:
# Clear system logs
sudo journalctl --vacuum-time=1s
# Clear traditional logs
sudo find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
sudo rm -f /var/log/wtmp /var/log/btmp
Container Considerations
When working with containers, Linux guests need to be optimized for containerized environments:
Container Optimization:
- Minimal base images (Alpine, distroless)
- Single process per container principle
- Stateless application design
- Proper signal handling for graceful shutdowns
- Security context and user permissions
Docker-specific Considerations:
# Install Docker (Ubuntu/Debian)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add user to docker group
sudo usermod -aG docker $USER
# Enable Docker service
sudo systemctl enable docker
sudo systemctl start docker
Cloud Platform Integration
Different cloud platforms provide various tools and services for Linux guests:
AWS EC2:
- EC2 Instance Metadata Service (IMDS)
- AWS Systems Manager Agent
- CloudWatch Agent
- Elastic Block Store (EBS) optimization
Microsoft Azure:
- Azure Linux Agent (walinuxagent)
- Azure Monitor Agent
- Azure Security Center integration
Google Cloud Platform:
- Google Cloud SDK
- Stackdriver agents
- Compute Engine metadata
MCQs
Q1. Which tool is used to configure cloud instances during first boot?
a) vm-init
b) cloud-start
c) cloud-init
d) vm-bootstrap
Answer: c
Q2. What is the purpose of D-Bus machine-id?
a) Identifies kernel versions
b) Unique identifier for the system
c) Sets network hostnames
d) Tracks installed packages
Answer: b
Q3. Which driver type is commonly used for optimized performance in KVM virtualization?
a) IDE
b) SCSI
c) VirtIO
d) SATA
Answer: c
Q4. What should be done to SSH host keys when cloning a Linux system?
a) Keep them unchanged
b) Regenerate them
c) Delete them permanently
d) Copy them to a backup location
Answer: b
Quick Reference Commands
Disk Layout and Filesystem Utilities
lsblk # List block devices
fdisk /dev/sdX # Partition a disk
parted # Advanced disk partitioning
mount /dev/sdXn /mnt # Mount a partition
blkid # Get UUID and type of devices
lsof +D /mount/point # List open files in directory
df -h # Show disk usage
du -sh /path # Show directory size
Boot Manager
grub-install /dev/sdX # Install GRUB to disk
grub-mkconfig -o /boot/grub/grub.cfg # Generate GRUB config (Debian)
grub2-mkconfig -o /boot/grub2/grub.cfg # Generate GRUB config (RHEL)
update-grub # Update GRUB (Ubuntu shortcut)
grub-reboot "1>2" # Boot specific entry next time
Shared Libraries
ldd /path/to/binary # Show shared libraries
ldconfig # Update shared library cache
ldconfig -p # Print library cache
export LD_LIBRARY_PATH=/custom/lib/path # Set custom library path
objdump -p /path/to/binary | grep NEEDED # Show library dependencies
Debian Package Management
sudo apt update # Refresh package list
sudo apt install nginx # Install nginx
sudo apt remove --purge nginx # Remove package and configs
dpkg -i package.deb # Install a .deb package manually
apt-cache search apache # Search packages
apt show nginx # Show package details
sudo apt autoremove # Remove orphaned packages
RPM and YUM/DNF Package Management
rpm -ivh package.rpm # Install RPM package
rpm -qa # List installed RPM packages
rpm -e package-name # Remove RPM package
rpm -qf /path/to/file # Find package owning file
yum install httpd # Install Apache via YUM
dnf install httpd # Install Apache via DNF
yum remove httpd # Remove Apache
yum update # Update all packages
yum search keyword # Search for packages
yum info package-name # Show package information
yum groupinstall "Development Tools" # Install package group
Virtualization Guest Prep
# Reset machine ID for cloning
sudo rm -f /etc/machine-id
sudo systemd-machine-id-setup
# Regenerate SSH host keys
sudo rm -f /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server # Debian/Ubuntu
sudo ssh-keygen -A # RHEL/CentOS
# Clean logs for template creation
sudo journalctl --vacuum-time=1s
sudo find /var/log -name "*.log" -exec truncate -s 0 {} \;
# Remove network persistence rules
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
System Information and Troubleshooting
# System information
uname -a # Kernel and system info
lscpu # CPU information
free -h # Memory usage
lsblk -f # Filesystem information
systemctl status service-name # Service status
# Package troubleshooting
apt list --upgradable # Show available upgrades
yum history # YUM transaction history
rpm -Va # Verify all packages
dpkg --audit # Find broken packages
Advanced Topics and Best Practices
LVM Management
# Physical Volume operations
pvcreate /dev/sdb1 # Create physical volume
pvdisplay # Show physical volumes
pvremove /dev/sdb1 # Remove physical volume
# Volume Group operations
vgcreate vg_data /dev/sdb1 /dev/sdc1 # Create volume group
vgdisplay # Show volume groups
vgextend vg_data /dev/sdd1 # Add PV to VG
vgreduce vg_data /dev/sdd1 # Remove PV from VG
# Logical Volume operations
lvcreate -L 10G -n lv_home vg_data # Create logical volume
lvdisplay # Show logical volumes
lvextend -L +5G /dev/vg_data/lv_home # Extend logical volume
lvresize -L 15G /dev/vg_data/lv_home # Resize logical volume
UEFI and Secure Boot
# Check if system is UEFI
ls /sys/firmware/efi # Directory exists if UEFI
# UEFI boot management
efibootmgr # List boot entries
efibootmgr -c -d /dev/sda -p 1 -L "Ubuntu" -l \\EFI\\ubuntu\\grubx64.efi
# Create boot entry
# Secure Boot status
mokutil --sb-state # Check Secure Boot status
Container Integration
# Docker commands for Linux guests
docker run -d --name nginx nginx # Run container
docker ps # List running containers
docker logs nginx # View container logs
docker exec -it nginx /bin/bash # Execute command in container
# Podman (rootless containers)
podman run -d --name nginx nginx # Run rootless container
podman pod create --name mypod # Create pod
Security Considerations
Package Security
# Verify package signatures (Debian)
apt-key list # List GPG keys
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_ID
# Verify package signatures (RPM)
rpm --checksig package.rpm # Check package signature
rpm -K package.rpm # Verify package integrity
# Security updates
apt list --upgradable | grep security # Show security updates
yum --security check-update # Check for security updates
yum update --security # Install only security updates
System Hardening for Templates
# Disable unused services
systemctl list-unit-files --type=service --state=enabled
systemctl disable unnecessary-service
# Set proper file permissions
chmod 600 /etc/ssh/sshd_config
chmod 644 /etc/passwd
chmod 640 /etc/shadow
# Configure automatic updates (Debian/Ubuntu)
apt install unattended-upgrades
dpkg-reconfigure unattended-upgrades
# Configure automatic updates (RHEL/CentOS)
yum install yum-cron
systemctl enable yum-cron
Troubleshooting Common Issues
Boot Problems
# GRUB rescue mode
grub rescue> ls # List partitions
grub rescue> set root=(hd0,1) # Set root partition
grub rescue> insmod normal # Load normal module
grub rescue> normal # Start normal boot
# Check boot logs
journalctl -b # Current boot logs
journalctl -b -1 # Previous boot logs
Package Dependency Issues
# Fix broken dependencies (Debian)
sudo apt --fix-broken install
sudo dpkg --configure -a
# Fix broken dependencies (RPM)
yum deplist package-name # Show dependencies
rpm -qpR package.rpm # Show package requirements
yum history undo ID # Undo transaction
Library Issues
# Find missing libraries
ldd /usr/bin/program | grep "not found"
# Rebuild library cache
sudo ldconfig -v
# Check library paths
echo $LD_LIBRARY_PATH
cat /etc/ld.so.conf
Virtualization Performance
# Check virtual hardware
lscpu | grep Virtualization
lsmod | grep virt # Check for virtio modules
dmesg | grep -i virtual # Check virtualization messages
# Install guest tools
# VMware
sudo apt install open-vm-tools # Ubuntu
sudo yum install open-vm-tools # RHEL/CentOS
# VirtualBox
sudo apt install virtualbox-guest-additions-iso
Exam Tips and Study Strategy
Key Areas to Focus On
- Disk Partitioning: Practice with fdisk, parted, and understand MBR vs GPT
- GRUB Configuration: Know the difference between GRUB Legacy and GRUB 2
- Package Management: Master both APT (Debian) and YUM/DNF (Red Hat) ecosystems
- Shared Libraries: Understand ldd, ldconfig, and library path configuration
- Virtualization: Know cloud-init basics and system preparation for cloning
Common Exam Scenarios
- Creating partition layouts with separate /home, /var, and /boot
- Installing and configuring GRUB on both UEFI and BIOS systems
- Resolving package dependency conflicts
- Troubleshooting missing shared libraries
- Preparing systems for virtualization and cloud deployment
Hands-on Practice Recommendations
- Set up virtual machines with different Linux distributions
- Practice partitioning schemes on test systems
- Break and fix GRUB configurations
- Work with both .deb and .rpm packages
- Create and deploy system templates
- Experiment with container deployments
Conclusion
Linux installation and package management are core skills for any system administrator. Mastering disk layouts, package tools (APT, YUM/DNF), GRUB configuration, and virtualization builds the foundation for advanced topics like automation, cloud deployment, and containers. Hands-on practice, understanding key config files, and using safe lab environments are essential for real-world readiness and certifications like LPIC-1 or RHCSA. While tools evolve, these fundamentals remain vital. Keep learning, stay updated, and grow with the Linux community to adapt to emerging technologies. Practice more with our free quiz: Linux Installation and Package Management Quiz – LPIC-1