Unit3 - Subjective Questions
CSC202 • Practice Questions with Detailed Answers
Explain the concept of Package Management Systems in Linux. What are the key advantages of using a package manager over manual installation?
A Package Management System is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer's operating system in a consistent manner.
Key Advantages:
- Dependency Resolution: Automatically identifies and installs libraries or other packages required by the software being installed.
- Centralized Repositories: Software is downloaded from trusted, maintained sources rather than random websites.
- Version Control: Keeps track of installed versions and allows for easy upgrades or rollbacks.
- Integrity Verification: Uses checksums and GPG signatures to ensure the package has not been tampered with.
- Clean Removal: Maintains a database of files installed, allowing for complete removal without leaving orphan files.
Differentiate between RPM (Red Hat Package Manager) and YUM/DNF. How do they interact with each other?
RPM and YUM/DNF act at different layers of software management in Red Hat-based systems:
1. RPM (Low-level):
- Function: It is the backend tool used to install, query, verify, update, and erase individual software packages.
- Limitation: It does not resolve dependencies automatically. If package A depends on package B, RPM will fail and tell you to install B first.
- Command:
rpm -ivh package.rpm
2. YUM/DNF (High-level):
- Function: These are front-end tools that interact with software repositories.
- Advantage: They automatically resolve dependencies. If you ask to install package A, YUM/DNF will calculate that B is needed, download both, and use RPM to install them in the correct order.
- Command:
dnf install package
Interaction: DNF/YUM essentially acts as a wrapper that manages repositories and dependency logic, while calling RPM in the background to perform the actual file placement.
Describe the standard naming convention of an RPM package file with an example.
RPM packages follow a strict naming convention to help administrators identify the software version and architecture before installation. The format is:
name-version-release.architecture.rpm
Breakdown using example httpd-2.4.6-90.el7.x86_64.rpm:
- Name (
httpd): The name of the software package (Apache Web Server). - Version (
2.4.6): The upstream version number of the software. - Release (
90.el7): The number of times this version of the package has been packaged by the OS vendor (Red Hat/CentOS).el7denotes Enterprise Linux 7. - Architecture (
x86_64): The hardware architecture the package is compiled for (64-bit Intel/AMD). Other types includenoarch(scripts/docs) oraarch64. - Extension (
.rpm): The file extension.
Explain the process of compiling software from source code in Linux. What are the standard three steps involved?
Compiling from source involves converting human-readable source code (usually C or C++) into machine-executable binaries. This is often distributed as a compressed 'tarball' (.tar.gz).
The Standard 3-Step Process:
-
Configuration (
./configure):- This script checks the local system environment for dependencies, compiler availability, and library locations.
- It creates a
Makefilecustomized for the specific system.
-
Compilation (
make):- This command reads the
Makefilegenerated in the previous step. - It compiles the source code files into binary object files and links them to create the final executable.
- This command reads the
-
Installation (
make install):- This step copies the compiled binaries, libraries, and documentation to the correct system directories (e.g.,
/usr/local/bin), requiring root privileges.
- This step copies the compiled binaries, libraries, and documentation to the correct system directories (e.g.,
Compare Debian-based package management tools (dpkg and apt) with Red Hat-based tools (rpm and dnf).
| Feature | Debian/Ubuntu (.deb) |
RHEL/CentOS/Fedora (.rpm) |
|---|---|---|
| Package Format | .deb |
.rpm |
| Low-Level Tool | dpkg (Debian Package) | rpm (Red Hat Package Manager) |
| Low-Level Usage | dpkg -i package.deb |
rpm -ivh package.rpm |
| High-Level Tool | apt (Advanced Package Tool) | dnf (Dandified YUM) or yum |
| High-Level Usage | apt install package |
dnf install package |
| Repository Config | /etc/apt/sources.list |
/etc/yum.repos.d/*.repo |
| Database Rebuild | dpkg --configure -a |
rpm --rebuilddb |
Both systems separate the duties between a low-level utility that handles the files and a high-level utility that handles dependencies and network repositories.
What is Sandboxing in the context of software management? Provide examples of technologies that utilize this concept.
Sandboxing is a software management and security technique where an application runs in an isolated environment (a "sandbox") that restricts its access to the host operating system's resources, files, and other running applications.
Key Characteristics:
- Isolation: If the application crashes or is compromised by malware, the damage is contained within the sandbox and does not affect the host OS.
- Resource Control: Administrators can limit CPU, memory, and network access for the sandboxed app.
Technologies/Examples:
- Snap and Flatpak: Universal package managers that bundle dependencies and run apps in isolation from the core OS libraries.
- Docker/Podman: Containerization technologies that run services in isolated user spaces sharing the host kernel.
- SELinux/AppArmor: Mandatory Access Control systems that enforce sandbox-like restrictions on standard processes.
Explain the structure of an APT repository configuration in /etc/apt/sources.list.
The /etc/apt/sources.list file tells the APT package manager where to download packages from. A typical line follows this format:
type archive_url distribution component1 component2
Detailed Breakdown:
- Type:
deb: Repositories containing pre-compiled binary packages.deb-src: Repositories containing the original source code.
- Archive URL: The web address of the repository (e.g.,
http://archive.ubuntu.com/ubuntu). - Distribution: The codename of the OS release (e.g.,
jammy,focal,bullseye). - Components: Categories of software:
main: Officially supported, open-source software.restricted: Supported software with proprietary drivers.universe: Community-maintained open-source software.multiverse: Software restricted by copyright or legal issues.
Detailed the architecture of Logical Volume Management (LVM) using a diagrammatic explanation. What are the benefits of using LVM over standard partitioning?
Logical Volume Management (LVM) creates an abstraction layer between the physical storage hardware and the filesystem.
Architecture Hierarchy:
- Physical Volumes (PV): The lowest layer. These are actual physical hard drives or standard partitions (e.g.,
/dev/sdb1) initialized for LVM. - Volume Groups (VG): A storage pool created by combining one or more Physical Volumes. It acts as a single large disk.
- Formula:
- Logical Volumes (LV): Virtual partitions created from the space available in the Volume Group. Filesystems are created on these LVs.
Flow:
Benefits:
- Flexibility: LVs can be resized (extended/reduced) dynamically without reformating.
- Spanning: A single Logical Volume can span across multiple physical disks.
- Snapshots: LVM supports taking point-in-time snapshots for backups without stopping services.
Distinguish between MBR (Master Boot Record) and GPT (GUID Partition Table) partitioning schemes.
| Feature | MBR (Master Boot Record) | GPT (GUID Partition Table) |
|---|---|---|
| History | Legacy standard (early 1980s). | Modern standard (part of UEFI). |
| Max Disk Size | Supports up to 2 TB. | Supports up to 9.4 ZB (Zettabytes). |
| Partition Limit | Max 4 primary partitions. Uses extended partitions for more. | Max 128 partitions by default in Windows/Linux. |
| Robustness | Boot data stored in one place (start of disk). Susceptible to corruption. | Stores backup header at the end of the disk. CRC32 checksums used. |
| Identification | Uses 32-bit identifiers. | Uses 128-bit Universally Unique Identifiers (UUID). |
For modern systems, especially those with drives larger than 2TB, GPT is required.
What are software repositories? How do you add a third-party repository in a YUM/DNF based system?
Software Repositories are central storage locations (usually servers on the internet) from which software packages may be retrieved and installed on a computer.
Adding a Third-Party Repository in YUM/DNF:
There are two common methods to add a repo:
-
Using
dnf config-manager(Recommended):- Command:
sudo dnf config-manager --add-repo https://example.com/repo/name.repo - This automatically downloads the
.repofile and places it in the correct directory.
- Command:
-
Manual Creation:
-
Create a file in
/etc/yum.repos.d/with a.repoextension (e.g.,myapp.repo). -
Add the configuration:
ini
[my-repo-id]
name=My Custom Repository
baseurl=https://example.com/path/to/repo/
enabled=1
gpgcheck=1
gpgkey=https://example.com/path/to/key.gpg -
Run
dnf clean allanddnf makecacheto update the repository metadata.
-
Describe the function of the /etc/fstab file. What happens if this file is misconfigured?
The /etc/fstab (Filesystem Table) is a system configuration file that contains information about all the partitions and storage devices that should be automatically mounted by the OS at boot time.
Fields in fstab:
- Device: UUID or device path (e.g.,
/dev/sdb1). - Mount Point: Directory where the device is attached (e.g.,
/home). - Filesystem Type: e.g.,
xfs,ext4,swap. - Options: Mount options (e.g.,
defaults,noatime,ro). - Dump: Backup utility flag (0 or 1).
- Fsck: File system check order (0, 1, or 2).
Consequences of Misconfiguration:
If /etc/fstab contains syntax errors or references a UUID that does not exist:
- The system may fail to boot into the standard mode.
- It often drops into Emergency Mode or a root shell, requiring the administrator to remount the filesystem as read-write (
mount -o remount,rw /) and fix the file manually.
Explain RAID (Redundant Array of Independent Disks). Compare RAID 0, RAID 1, and RAID 5 in terms of redundancy and storage capacity.
RAID is a virtualization technology that combines multiple physical disk drive components into one or more logical units for data redundancy, performance improvement, or both.
Comparison:
-
RAID 0 (Striping):
- Concept: Splits data evenly across two or more disks.
- Redundancy: None. If one disk fails, all data is lost.
- Capacity:
- Use Case: High performance, non-critical data.
-
RAID 1 (Mirroring):
- Concept: Writes the exact same data to two disks simultaneously.
- Redundancy: High. Can survive the loss of one disk.
- Capacity: (50% efficiency with 2 disks).
- Use Case: OS drives, critical data.
-
RAID 5 (Striping with Parity):
- Concept: Stripes data and parity information across three or more disks.
- Redundancy: Can survive the failure of one disk. Data is reconstructed using parity.
- Capacity: (where N is number of disks).
- Use Case: File servers balancing performance and safety.
What are checksums and GPG keys? How are they used during software acquisition to ensure security?
When acquiring software, ensuring the file hasn't been corrupted or maliciously altered is crucial.
1. Checksums (Integrity):
- Definition: A calculated value (hash) derived from the file's contents using algorithms like SHA-256 or MD5.
- Usage: After downloading a file, the user runs a tool (e.g.,
sha256sum filename). If the output matches the checksum published by the developer on their website, the file is intact and corruption-free.
2. GPG Keys (Authenticity):
- Definition: GNU Privacy Guard keys involve a public/private key pair used for signing packages.
- Usage:
- The developer signs the package with their private key.
- The user imports the developer's public key.
- The package manager (RPM/APT) uses the public key to verify the signature. This proves the software actually came from the claimed developer and wasn't intercepted/replaced by an attacker.
Describe the steps to deploy a new storage drive in a Linux system (Partitioning -> Formatting -> Mounting).
To make a new hard drive usable in Linux, follow these steps:
1. Partitioning (Create the container):
- Identify the disk using
lsblkorfdisk -l(e.g.,/dev/sdb). - Use a tool like
fdisk(for MBR) orgdisk(for GPT). - Create a new partition (e.g.,
/dev/sdb1) by specifying start and end sectors. - Write changes to the disk.
2. Formatting (Create the Filesystem):
- Apply a filesystem structure to the partition to organize files.
- Command:
mkfs.ext4 /dev/sdb1ormkfs.xfs /dev/sdb1.
3. Mounting (Attach to the Tree):
- Create a directory to serve as the mount point:
mkdir /mnt/data. - Mount the partition temporarily:
mount /dev/sdb1 /mnt/data. - For persistence, add an entry to
/etc/fstab.
Explain the concept of Swap Storage. How do you create a swap file?
Swap Storage is a space on a disk that is used when the amount of physical RAM is full. When the OS needs more memory than is physically available, it moves inactive pages from RAM to the Swap space (paging out). It acts as an overflow for RAM.
Creating a Swap File:
- Create the file: Allocate disk space (e.g., 1GB).
dd if=/dev/zero of=/swapfile bs=1M count=1024
- Set Permissions: Ensure only root can read/write.
chmod 600 /swapfile
- Format as Swap: Initialize the file as swap space.
mkswap /swapfile
- Activate: Enable the swap file.
swapon /swapfile
- Persist: Add to
/etc/fstabto load on boot./swapfile none swap sw 0 0
Describe Network Attached Storage (NAS) protocols commonly used in Linux: NFS and SMB/CIFS.
Network storage allows accessing files over a network as if they were local.
1. NFS (Network File System):
- Environment: Native to Unix/Linux systems.
- Function: Allows a server to export a directory which clients mount into their local filesystem tree.
- Configuration: Server uses
/etc/exportsto define shared directories and client permissions. - Pros: High performance for Linux-to-Linux sharing, preserves Unix file permissions.
2. SMB/CIFS (Server Message Block):
- Environment: Native to Windows, but supported in Linux via Samba.
- Function: Enables file sharing between mixed environments (Windows clients accessing Linux servers or vice versa).
- Configuration: Configured via
/etc/samba/smb.conf. - Pros: Essential for heterogeneous networks (Linux/Windows interoperability).
Discuss how to troubleshoot storage issues related to full disks and inode exhaustion.
When a system reports "No space left on device," it can be due to data size or inode exhaustion.
1. Troubleshooting Disk Space Usage:
- Check overall usage: Run
df -h. This shows the percentage used for every mounted partition. - Locate large files: If a partition is full, drill down using
du(Disk Usage).du -sh /*(shows size of top-level directories).du -ah /var | sort -rh | head -10(finds top 10 largest files/folders in/var).
2. Troubleshooting Inode Exhaustion:
- Concept: Every file consumes one inode (index node). If you have millions of tiny files, you may run out of inodes even if you have GBs of space left.
- Check inodes: Run
df -i. Check theIUse%column. - Solution: Find directories with many small files (often session files, mail queues, or temp files) and delete them or archive them.
What is fsck? When should it be used, and what precautions must be taken?
fsck (File System Consistency Check) is a utility for checking the consistency of a file system and repairing errors (e.g., corrupt superblocks, unlinked inodes).
When to use:
- After an improper shutdown (power failure).
- When the system boots into emergency mode due to filesystem errors.
- Periodically on external drives that are behaving erratically.
Precautions:
- Unmount First: NEVER run
fsckon a mounted, read-write filesystem. Doing so will almost certainly corrupt the data further because the OS may write to the disk whilefsckis modifying structures. - Boot Media: For the root partition, you often need to boot from a Live CD/USB or into single-user mode (where root is mounted read-only) to run
fscksafely. - Data Loss: While
fscktries to save data, aggressive repair options can lead to data loss (files moved to/lost+found).
Explain the concept of Disk Quotas. How do soft limits differ from hard limits?
Disk Quotas allow system administrators to limit the amount of disk space or the number of files (inodes) a user or group can use on a filesystem. This prevents a single user from filling up the entire hard drive and crashing the system.
Types of Limits:
-
Soft Limit:
- This is a warning level.
- A user can exceed the soft limit temporarily (for a "grace period," usually 7 days).
- If the user remains above the soft limit after the grace period expires, it becomes a hard limit.
-
Hard Limit:
- This is the absolute maximum ceiling.
- The system will physically block the user from writing any more data immediately upon reaching this limit.
- Example error: "Disk quota exceeded."
Compare Static Partitioning vs. Dynamic Partitioning (LVM). Why is LVM preferred in enterprise environments?
Static Partitioning:
- Involves writing the partition table directly to the disk (MBR/GPT).
- Rigid: If
/varfills up, you cannot easily "borrow" space from/homeunless they are adjacent and you unmount/format partitions. - Simple: Easier to set up for simple desktop use cases.
Dynamic Partitioning (LVM):
- Involves pooling disks into a Volume Group.
- Fluid: Logical volumes can be resized online. New physical disks can be added to the pool to expand existing filesystems on the fly.
Why LVM is preferred in Enterprise:
- Uptime: Servers often cannot afford downtime. LVM allows expanding storage without rebooting.
- Agility: Storage needs change. LVM allows admins to allocate space conservatively and grow volumes as needed.
- Features: Enterprise features like mirroring and striping are built-in software capabilities of LVM.