Unit 1: Linux Ecosystem & Infrastructure Laboratory
1. Laboratory Overview & System Architecture
The Linux operating system represents an open-source, POSIX-compliant Unix-like operating system built upon the monolithic Linux kernel originally conceived by Linus Torvalds. In professional systems engineering and enterprise environments, understanding the low-level infrastructure, file hierarchy, user privilege boundaries, and stream redirection mechanics is fundamental.
CODELinux OS Layered Architecture ┌────────────────────────────────────────────────────────┐ │ User Space Applications (Bash, Vim, GCC, Python, Web) │ ├────────────────────────────────────────────────────────┤ │ GNU C Library (glibc) / System Call Interface (SCI) │ ├────────────────────────────────────────────────────────┤ │ Linux Kernel Subsystems: │ │ - Process Scheduler (CFS) │ │ - Virtual File System (VFS: ext4, xfs, btrfs) │ │ - Memory Management (MMU, Paging, Slab Allocator) │ │ - Network Stack (TCP/IP, Netfilter) │ │ - Architecture-Dependent Device Drivers │ ├────────────────────────────────────────────────────────┤ │ Physical Hardware (CPU, RAM, Disks, Network Adapters) │ └────────────────────────────────────────────────────────┘
1.1 Linux Distribution Families
Because the Linux kernel is modular and open-source, operating system vendors bundle the kernel with the GNU userland toolchain, desktop environments, system daemons (systemd), and package managers into distinct Distributions (Distros):
| Distribution Family | Reference Distro | Package Format | High-Level Tool | Low-Level Tool | Target Architecture / Use-Case |
|---|---|---|---|---|---|
| Debian Family | Debian, Ubuntu, Kali, Mint | .deb | apt, apt-get | dpkg | General server stability, desktop usability, cybersecurity. |
| Red Hat Family | RHEL, Fedora, Rocky, Alma | .rpm | dnf (formerly yum) | rpm | Enterprise data centers, mission-critical server clouds. |
| SUSE Family | openSUSE, SLES | .rpm | zypper | rpm | European enterprise workloads, SAP deployments. |
| Arch Family | Arch Linux, Manjaro | pkg.tar.zst | pacman | pacman | Rolling-release, bleeding-edge enthusiast and dev desktop. |
2. Lab Experiment 1: Linux CLI Environment Setup & Filesystem Hierarchy Standard (FHS) Navigation
2.1 Aim
To configure a Linux terminal environment, explore the Filesystem Hierarchy Standard (FHS), and execute directory traversal and state-inspection commands.
2.2 Theoretical Concepts
The Linux directory layout follows the Filesystem Hierarchy Standard (FHS), which mandates a unified, single-rooted hierarchical tree (/) regardless of underlying physical disk partitions:
/: The single root directory containing all subtrees./bin&/usr/bin: Essential binary executable commands for all users (ls,cp,bash)./sbin&/usr/sbin: System binaries reserved for administrative execution (fdisk,reboot,iptables)./etc: Host-specific system-wide configuration text files (/etc/passwd,/etc/fstab,/etc/hosts)./home: Personal user workspaces storing dotfiles and application settings (/home/username/)./root: The distinct home directory for the administrative superuser (root)./var: Variable data directories housing dynamic runtime logs (/var/log/), spool files, and mail queues./tmp: Temporary scratch space cleared on system reboot./dev: Special device nodes created byudevrepresenting hardware peripherals (/dev/sda,/dev/null,/dev/urandom)./proc&/sys: Virtual pseudo-filesystems exposing kernel internals, active process states, and hardware runtime data.
CODELinux Filesystem Hierarchy Tree (FHS) / (Root) ┌────────┬────────┬────────┬──┴─────┬────────┬────────┬────────┐ │ │ │ │ │ │ │ │ /bin /etc /home /var /tmp /dev /proc /usr │ │ │ │ │ /alice /log/syslog /sda1 /cpuinfo /bin
2.3 Step-by-Step Laboratory Procedure
- Launch terminal emulator (or SSH into server). Verify current shell:
bash
echo $SHELL - Display the absolute pathname of the active working directory:
bash
pwd - List all files including hidden dotfiles and permission details in
/:bashls -la / - Traverse into the system configuration directory:
bash
cd /etc pwd - Inspect CPU hardware specifications and memory layout via pseudo-filesystems:
bash
cat /proc/cpuinfo | grep "model name" | head -n 1 cat /proc/meminfo | head -n 4 - Return to user home directory using the tilde (
~) shorthand:bashcd ~ pwd
2.4 Sample Terminal Session & Execution Output
terminal$ echo $SHELL /bin/bash $ pwd /home/developer $ ls -ld /home/developer drwxr-xr-x 18 developer developer 4096 Oct 17 10:14 /home/developer $ cd /etc && pwd /etc $ cat /proc/cpuinfo | grep "model name" | head -n 1 model name : AMD EPYC 7763 64-Core Processor $ cat /proc/meminfo | head -n 2 MemTotal: 32880196 kB MemFree: 21549840 kB $ cd ~ && pwd /home/developer
3. Lab Experiment 2: File Manipulation, Stream Redirection & Pipeline Processing
3.1 Aim
To create, manipulate, and search files using standard Unix stream filters, pipeline redirection operators, and file examination utilities.
3.2 Theoretical Concepts & Stream Architecture
Every running Linux process is initialized by the kernel with three standard POSIX I/O streams bound to default file descriptors (FDs):
- Standard Input (
stdin, File Descriptor 0): Default source of data input (keyboard). - Standard Output (
stdout, File Descriptor 1): Default destination for regular output (terminal display). - Standard Error (
stderr, File Descriptor 2): Default destination for diagnostic and error messages (terminal display).
CODEPOSIX Standard Streams & Redirection ┌──────────────────────────┐ Keyboard ─────────►│ stdin (FD 0) │ │ │ │ Executing Process │ │ │ Screen / File ◄────│ stdout (FD 1: > or >>) │ Error Log ◄────│ stderr (FD 2: 2> or 2>>) │ └──────────────────────────┘
Stream Redirection Operators:
>: Redirectsstdoutto a file, truncating and overwriting existing contents.>>: Redirectsstdoutto a file, appending new data to the end of the file.<: Redirectsstdinfrom an existing file.2>: Redirectsstderrstream explicitly to a designated file.&>or2>&1: Combinesstdoutandstderrstreams into a single output destination.|(Pipe): Connects thestdoutstream of command directly into thestdinstream of command .
3.3 Step-by-Step Laboratory Procedure
- Create a structured project workspace directory:
bash
mkdir -p ~/lab_workspace/data cd ~/lab_workspace/data - Generate a synthetic log file using
catandEOFhere-document redirection:bashcat << 'EOF' > system.log 2026-10-17 10:01:12 INFO [auth] User admin logged in from 192.168.1.50 2026-10-17 10:02:15 WARN [kernel] CPU frequency thermal throttling initiated 2026-10-17 10:03:01 ERROR [disk] I/O latency spike on /dev/sda1 sector 48201 2026-10-17 10:04:22 INFO [auth] User alice logged in from 192.168.1.104 2026-10-17 10:05:44 ERROR [auth] Failed password for root from 203.0.113.19 2026-10-17 10:06:10 ERROR [auth] Failed password for root from 203.0.113.19 EOF - Filter all error log entries into a dedicated file:
bash
grep "ERROR" system.log > errors.log cat errors.log - Extract unique remote IP addresses attempting brute-force logins using a command pipeline:
bash
grep "Failed password" system.log | awk '{print $NF}' | sort | uniq -c - Count total lines, words, and byte lengths in
system.log:bashwc system.log - Duplicate output to both the screen and a secondary file simultaneously using
tee:bashhead -n 3 system.log | tee sample_summary.txt
3.4 Sample Terminal Output
terminal$ cat errors.log 2026-10-17 10:03:01 ERROR [disk] I/O latency spike on /dev/sda1 sector 48201 2026-10-17 10:05:44 ERROR [auth] Failed password for root from 203.0.113.19 2026-10-17 10:06:10 ERROR [auth] Failed password for root from 203.0.113.19 $ grep "Failed password" system.log | awk '{print $NF}' | sort | uniq -c 2 203.0.113.19 $ wc system.log 6 57 412 system.log $ head -n 3 system.log | tee sample_summary.txt 2026-10-17 10:01:12 INFO [auth] User admin logged in from 192.168.1.50 2026-10-17 10:02:15 WARN [kernel] CPU frequency thermal throttling initiated 2026-10-17 10:03:01 ERROR [disk] I/O latency spike on /dev/sda1 sector 48201
4. Lab Experiment 3: Multi-User Account Provisioning & Security Administration
4.1 Aim
To demonstrate user account creation, group memberships, shadow password security mechanisms, and the configuration of privilege delegation using sudo.
4.2 Theoretical Concepts
Linux enforces multi-user access security via dedicated kernel identities:
- User Identifier (UID): A 32-bit unsigned integer identifying accounts (
root = UID 0, system daemons =UID 1-999, regular human users =UID >= 1000). - Group Identifier (GID): Associates multiple users for collaborative resource sharing.
System Security Databases:
/etc/passwd: Publicly readable database storing account properties formatted with seven colon-separated fields:
username:password_placeholder(x):UID:GID:GECOS_Comment:home_directory:login_shell/etc/shadow: Restricted file (readable only by root, permissions0640or0000) containing one-way salted cryptographic password hashes and account expiration policies:
username:$id$salt$hash:last_change:min_days:max_days:warn_days:inactive:expire/etc/group: Defines groups and secondary memberships:
groupname:password_placeholder(x):GID:user_list
CODE/etc/passwd Entry Breakdown alice : x : 1001 : 1001 : Alice Smith,Room 402 : /home/alice : /bin/bash │ │ │ │ │ │ │ Username │ UID GID GECOS Comment Home Dir Shell Password Flag (x -> stored in /etc/shadow)
4.3 Step-by-Step Laboratory Procedure
- Create a new developer group with a custom GID:
bash
sudo groupadd -g 2000 devteam grep "devteam" /etc/group - Provision a new user account with a home directory and default bash shell:
bash
sudo useradd -u 1500 -g devteam -m -s /bin/bash -c "Senior Developer" devuser - Set the user's password securely:
bash
sudo passwd devuser - Verify entries across
/etc/passwdand/etc/shadow:bashgrep "devuser" /etc/passwd sudo grep "devuser" /etc/shadow | cut -d: -f1,2 - Append
devuserto the secondary administrative group (wheelorsudo):bashsudo usermod -aG sudo devuser id devuser - Clean up: Delete test account and purge home directory:
bash
sudo userdel -r devuser sudo groupdel devteam
4.4 Sample Terminal Session Output
terminal$ sudo groupadd -g 2000 devteam $ grep "devteam" /etc/group devteam:x:2000: $ sudo useradd -u 1500 -g devteam -m -s /bin/bash -c "Senior Developer" devuser $ grep "devuser" /etc/passwd devuser:x:1500:2000:Senior Developer:/home/devuser:/bin/bash $ sudo usermod -aG sudo devuser $ id devuser uid=1500(devuser) gid=2000(devteam) groups=2000(devteam),27(sudo)
5. Lab Experiment 4: File Security, Access Control (DAC) & Special Permission Modes
5.1 Aim
To configure Discretionary Access Control (DAC) permissions using symbolic and octal modes, modify ownership, and implement special permission bits (SUID, SGID, and Sticky Bit).
5.2 Theoretical Concepts
Every file in Linux possesses a 16-bit file mode tracked within its inode:
- 4 bits: File type (regular, directory, symlink, socket, fifo, block, character).
- 3 bits: Special execution flags (SUID, SGID, Sticky Bit).
- 9 bits: Classic Read (
r=4), Write (w=2), Execute (x=1) permissions for User, Group, and Others.
CODEFile Mode Bitmask Anatomy ┌───────────┬──────────────┬──────────────┬──────────────┐ │ Special │ User (Owner) │ Group │ Others │ │ SUID SGID │ Read Write Ex│ Read Write Ex│ Read Write Ex│ │ 4 2 │ 4 2 1 │ 4 2 1 │ 4 2 1 │ └───────────┴──────────────┴──────────────┴──────────────┘
Special Permission Characteristics:
- SetUID (SUID, Octal 4000):
- When set on an executable binary, any unprivileged user executing the program temporarily assumes the effective UID of the file's owner (e.g.,
/usr/bin/passwdruns asrootto modify/etc/shadow). Represented assin user execute field (-rwsr-xr-x).
- When set on an executable binary, any unprivileged user executing the program temporarily assumes the effective UID of the file's owner (e.g.,
- SetGID (SGID, Octal 2000):
- On an executable: Executes with the file group's GID.
- On a directory: Any new files created inside inherit the directory's group owner, rather than the primary group of the creating user. Crucial for team collaboration. Represented as
sin group execute field (drwxrwsr-x).
- Sticky Bit (Octal 1000):
- Applied to shared directories (e.g.,
/tmp). Restricts file deletion: a user can only delete or rename files they personally own, even if write permissions are granted to everyone. Represented astin others execute field (drwxrwxrwt).
- Applied to shared directories (e.g.,
5.3 Step-by-Step Laboratory Procedure
- Create a shared team collaboration directory:
bash
sudo mkdir -p /var/projects/backend sudo chown root:devteam /var/projects/backend - Set directory permissions with SGID and full group access:
bash
sudo chmod 2775 /var/projects/backend ls -ld /var/projects/backend - Demonstrate Sticky Bit on shared scratch directories:
bash
mkdir -p /tmp/shared_collab chmod 1777 /tmp/shared_collab ls -ld /tmp/shared_collab - Verify symbolic vs octal manipulation:
bash
touch testfile.sh chmod 700 testfile.sh # rwx------ chmod g+rx testfile.sh # rwxr-x--- chmod o-rwx testfile.sh # rwxr-x--- ls -l testfile.sh
5.4 Sample Terminal Output
terminal$ ls -ld /var/projects/backend drwxrwsr-x 2 root devteam 4096 Oct 17 11:20 /var/projects/backend $ ls -ld /tmp/shared_collab drwxrwxrwt 2 user devteam 4096 Oct 17 11:22 /tmp/shared_collab $ ls -l testfile.sh -rwxr-x--- 1 user devteam 0 Oct 17 11:24 testfile.sh
6. Lab Experiment 5: Software Package Lifecycle & Repository Management
6.1 Aim
To manage software packages, repositories, automated dependencies, and universal containerized sandboxed applications using high-level and low-level package utilities.
6.2 Theoretical Concepts
A Package Manager automates software installation, dependency graph resolution, verification, configuration, and removal:
- Repository (Repo): A remote HTTPS/FTP server hosting signed packages and metadata indices.
- Dependency Resolution: When package depends on library , tools like
aptordnfrecursively identify and fetch required libraries. - Low-Level Managers (
dpkg,rpm): Install individual standalone archives directly; they fail if dependencies are missing. - Universal Sandboxed Formats (Flatpak, Snap): Bundle applications with their complete runtime dependencies into isolated containers, eliminating "dependency hell" across different distributions.
CODEPackage Management Hierarchy High-Level Tools (Automatic Dependencies) ┌────────────┬────────────┐ │ apt │ dnf │ └─────┬──────┴─────┬──────┘ │ │ ▼ ▼ ┌────────────┬────────────┐ │ dpkg │ rpm │ Low-Level Format Handlers └─────┬──────┴─────┬──────┘ ▼ ▼ .deb Files .rpm Files
6.3 Step-by-Step Laboratory Procedure
- Refresh local package index databases:
bash
sudo apt update - Search repository for a network monitoring utility:
bash
apt search htop - Install package and inspect package metadata:
bash
sudo apt install -y htop dpkg -s htop - Query which package owns a specific executable binary on the system:
bash
dpkg -S /usr/bin/htop - Remove the package while purging configuration files:
bash
sudo apt purge -y htop sudo apt autoremove -y
6.4 Sample Terminal Output
terminal$ dpkg -s htop | grep -E "Package|Version|Status|Description" Package: htop Status: install ok installed Version: 3.2.2-1 Description: interactive processes viewer $ dpkg -S /usr/bin/htop htop: /usr/bin/htop
7. Viva Voce & Laboratory Review Questions
- Why does Linux place executable binaries in
/binversus/sbin?/bincontains general commands accessible to all system users (ls,grep,cp), whereas/sbinhouses administrative system binaries (iptables,fdisk,reboot) intended for the root superuser.
- What occurs when a command issues
rm -rf /? How does modern GNU coreutils protect systems?- It attempts to recursively and forcefully un-link all directory nodes starting from root. Modern GNU
rmenforces--no-preserve-rootto prevent accidental system destruction.
- It attempts to recursively and forcefully un-link all directory nodes starting from root. Modern GNU
- What is the difference between
useraddandadduseron Debian systems?useraddis the compiled low-level C utility across all Linux distros.adduseris a user-friendly Perl wrapper script on Debian/Ubuntu that prompts interactively for passwords, creates home directories, and populates skel files automatically.
- Why is password information moved from
/etc/passwdto/etc/shadow?/etc/passwdmust be world-readable so programs can map UIDs to human names (e.g.,ls -l). Keeping password hashes in/etc/passwdexposed hashes to offline dictionary attacks./etc/shadowrestricts read permissions exclusively to root.
- How does the Sticky Bit protect shared team directories?
- On directories with permissions
1777(/tmp), any user can create files, but a user is strictly prohibited from deleting or renaming files owned by others.
- On directories with permissions