Introduction to Linux

Linux stands as one of the most significant technological achievements in modern computing—an open-source, free operating system whose stability, security, and multi-concurrent processing capabilities have earned universal industry recognition. Today, virtually every enterprise-level project (whether built with C/C++, PHP, Python, Java, or Go) deploys on Linux or Unix-based systems.

Understanding Linux isn't merely an optional skill for developers—it's a fundamental requirement for anyone serious about software development, system administration, or infrastructure engineering. This comprehensive guide walks you through Linux installation, configuration, and the essential directory structure that forms the foundation of the entire ecosystem.

Linux Distribution Landscape

It's crucial to understand that "Linux" technically refers only to the kernel—the core component that manages system resources. What most people call "Linux" are actually distributions (distros)—complete operating systems built around the Linux kernel with additional software, package managers, and configuration tools.

Major Linux Distributions

The Linux ecosystem offers numerous distributions, each targeting different use cases:

  • Ubuntu: User-friendly, excellent for beginners and desktop use
  • Red Hat Enterprise Linux (RHEL): Commercial distribution with enterprise support
  • CentOS: Community-driven, binary-compatible with RHEL (now transitioning to CentOS Stream)
  • Debian: Known for stability and strict free software guidelines
  • Fedora: Cutting-edge features, sponsored by Red Hat
  • SUSE/OpenSUSE: Popular in European enterprise environments

Each distribution brings unique characteristics, but they all share the same fundamental Linux kernel and directory structure—knowledge transfers seamlessly between them.


Linux Installation: Virtual Machine Setup

For learning and development purposes, installing Linux in a virtual machine provides the perfect balance of safety and functionality. You can experiment freely without risking your host system, take snapshots before major changes, and easily revert if something goes wrong.

Prerequisites: Virtualization Support

Before installing any virtual machine software, ensure your system supports hardware virtualization:

  1. Open Task Manager (Windows) or Activity Monitor (macOS)
  2. Navigate to Performance → CPU
  3. Verify that "Virtualization" shows as enabled

If virtualization is disabled, you'll need to:

  1. Restart your computer
  2. Enter BIOS/UEFI setup (typically by pressing F2, F10, or Delete during boot)
  3. Locate virtualization settings (Intel VT-x or AMD-V)
  4. Enable the feature
  5. Save changes and reboot

Step 1: Install Virtualization Software

VMware Workstation (version 15.5 or later recommended):

  • Download from the official VMware website
  • Run the installer with default settings
  • Accept the license agreement
  • Complete the installation and restart if prompted

Alternative Options:

  • VirtualBox: Free, open-source alternative
  • QEMU/KVM: Native Linux virtualization
  • Hyper-V: Built into Windows Pro editions
  • Parallels: Popular for macOS

Step 2: Download Linux Distribution

For this guide, we'll use CentOS 7.6 or CentOS 8.1 as examples. These versions offer excellent stability and widespread enterprise adoption.

Download links are typically available from:

  • Official distribution websites
  • Mirror servers (faster for specific regions)
  • Educational institution mirrors

Step 3: Create the Virtual Machine

Launch VMware and follow these steps:

  1. Create New Virtual Machine

    • Click "Create a New Virtual Machine"
    • Select "Custom (advanced)" for detailed configuration
    • Click Next
  2. Hardware Compatibility

    • Choose Workstation 15.x compatibility
    • Click Next
  3. Installation Media

    • Select "Installer disc image file (iso)"
    • Browse to your downloaded CentOS ISO
    • Click Next
  4. Operating System Selection

    • Choose "Linux" as guest OS
    • Select "CentOS 64-bit" as version
    • Click Next
  5. Virtual Machine Name

    • Enter a descriptive name (e.g., "CentOS-Learning")
    • Choose storage location
    • Click Next
  6. Processor Configuration

    • Allocate 2 CPU cores with 2 threads each
    • This provides adequate performance for learning
    • Click Next
  7. Memory Allocation

    • Assign 2-4 GB RAM depending on host capacity
    • Avoid over-allocating (leave resources for host)
    • Click Next
  8. Network Configuration

    • Select "Network Address Translation (NAT)"
    • This allows internet access without IP conflicts
    • Click Next
  9. I/O Controller Types

    • Accept default LSI Logic recommendations
    • Click Next
  10. Disk Type

    • Choose "SCSI" for best compatibility
    • Click Next
  11. Select Disk

    • Choose "Create a new virtual disk"
    • Click Next
  12. Specify Disk Capacity

    • Allocate 20-40 GB depending on intended use
    • Select "Store virtual disk as single file"
    • Click Next
  13. Specify Disk File

    • Accept default filename or customize
    • Click Next
  14. Review and Finish

    • Verify all settings
    • Click "Customize Hardware" for additional options
    • Click Finish

Step 4: Install CentOS

With the virtual machine created, power it on to begin OS installation:

  1. Boot from ISO

    • The VM automatically boots from the installation media
    • Wait for the boot menu to appear
  2. Language Selection

    • Choose your preferred language
    • For learning purposes, consider selecting Chinese or English based on comfort level
    • Click Continue
  3. Software Selection

    • Production environments: Choose "Minimal Install" for reduced attack surface
    • Learning/Development: Select "Server with GUI" or "Workstation" for desktop environment
    • This guide recommends GUI for easier learning
    • Click Done
  4. Installation Destination

    • Select your virtual disk
    • Choose "I will configure partitioning"
    • Click Done
  5. Manual Partitioning

    • Click the "+" button to add partitions:

    Boot Partition (/boot):

    • Size: 1 GB
    • Filesystem: ext4
    • Purpose: Stores boot loader and kernel files

    Swap Partition:

    • Size: 2 GB (or equal to RAM for hibernation support)
    • Filesystem: swap
    • Purpose: Virtual memory extension

    Root Partition (/):

    • Size: Remaining space (minimum 17 GB)
    • Filesystem: ext4
    • Purpose: Main system and application storage

    Click Done when partitioning is complete

  6. Network and Host Name

    • Enable network interface (toggle to ON)
    • Set a meaningful hostname (e.g., centos-dev)
    • Click Apply
    • Click Done
  7. Security Policy

    • For learning environments, you can disable security policy
    • This simplifies password requirements during setup
    • Click Done
  8. Begin Installation

    • Review all settings
    • Click "Begin Installation"
    • Installation proceeds automatically (5-15 minutes)
  9. Root Password and User Creation

    • While installation runs, set the root password
    • Create a regular user account for daily use
    • Use strong passwords even in learning environments
  10. Completion

    • Wait for installation to complete
    • Click "Reboot" when prompted
    • Remove installation media if necessary
    • System restarts into your new Linux installation

First Boot and Initial Configuration

After rebooting:

  1. License Information

    • Accept the license agreement
    • Click Done
  2. User Login

    • Enter your username and password
    • Log into the system
  3. Initial Updates

    sudo yum update -y

    Or for newer versions:

    sudo dnf update -y

Congratulations! You now have a fully functional Linux system ready for exploration and development.


Network Configuration Modes for Virtual Machines

Understanding network modes is crucial for effective virtual machine operation. Each mode serves different purposes and offers distinct advantages.

Bridged Mode

How It Works: The virtual machine receives an IP address from the same network as your host machine (e.g., host: 192.168.0.14, VM: 192.168.0.11).

Advantages:

  • VM appears as a separate device on your network
  • Full bidirectional communication with external systems
  • Other devices can directly access the VM

Disadvantages:

  • Risk of IP address conflicts with other network devices
  • DHCP server may assign the same IP to multiple devices
  • Less isolation from network threats

Best For: Servers that need to be accessible from other network devices

NAT Mode (Network Address Translation)

How It Works: The VM operates on a separate private network, accessing external networks through the host's connection.

Advantages:

  • No IP address conflicts (VM uses private addressing)
  • Good isolation from network threats
  • VM can access external networks

Disadvantages:

  • External devices cannot directly access the VM
  • Additional NAT overhead (minimal performance impact)
  • Port forwarding required for inbound connections

Best For: Development environments, learning, isolated testing

Host-Only Mode

How It Works: The VM can only communicate with the host machine—no external network access.

Advantages:

  • Maximum isolation and security
  • No risk of external network interference
  • Fast communication with host

Disadvantages:

  • No internet access
  • Cannot communicate with other network devices
  • Limited practical utility

Best For: Secure testing environments, malware analysis, isolated development


Virtual Machine Cloning: Efficient System Duplication

Once you've configured a Linux system to your satisfaction, cloning eliminates the need for repeated installations.

Method 1: Direct File Copy

Process:

  1. Shut down the virtual machine completely
  2. Navigate to the VM's storage directory
  3. Copy the entire VM folder to a new location
  4. In VMware: File → Open → Select the copied .vmx file
  5. Power on the cloned VM

Advantages:

  • Simple and straightforward
  • No special tools required
  • Works across different virtualization platforms

Considerations:

  • May require MAC address regeneration
  • Network settings might need adjustment
  • Larger storage requirement

Method 2: VMware Clone Feature

Process:

  1. Ensure the VM is powered off (required)
  2. Right-click the VM in VMware library
  3. Select Manage → Clone
  4. Follow the Clone Virtual Machine Wizard:

    • Choose clone type (full or linked)
    • Specify number of clones
    • Set destination folder
  5. Complete the wizard

Full Clone: Independent copy with all data duplicated
Linked Clone: Shares base disk, saving space but dependent on original

Advantages:

  • Automatic MAC address handling
  • Clean system configuration
  • Option for linked clones (space efficient)

Virtual Machine Snapshots: Time Travel for Your System

Snapshots preserve your VM's exact state at a specific moment, enabling instant rollback if experiments go wrong.

Creating Snapshots

  1. Ensure VM is running or suspended (not required to be off)
  2. Right-click the VM
  3. Select Snapshot → Take Snapshot
  4. Provide a descriptive name (e.g., "Before Apache Installation")
  5. Add optional description
  6. Click Take Snapshot

Restoring Snapshots

  1. Right-click the VM
  2. Select Snapshot → Snapshot Manager
  3. Browse the snapshot tree
  4. Select desired snapshot
  5. Click "Go To" to restore
  6. Confirm the restoration

Important Considerations:

  • Snapshots are not backups (they depend on the original disk)
  • Multiple snapshots can impact performance
  • Delete unnecessary snapshots to save space
  • Use snapshots for short-term state preservation, not long-term backup

VMware Tools: Enhanced Integration

VMware Tools significantly improves the virtual machine experience by enabling seamless integration between host and guest systems.

Benefits of VMware Tools

  • Improved Graphics Performance: Better screen resolution and 3D acceleration
  • Shared Folders: Easy file transfer between host and VM
  • Clipboard Sharing: Copy-paste between host and guest
  • Time Synchronization: Automatic clock alignment
  • Graceful Shutdown: Proper VM shutdown from host
  • Network Optimization: Enhanced network driver performance

Installation Steps

  1. Boot into CentOS and log in with root or sudo privileges
  2. Initiate Installation

    • In VMware menu: VM → Install VMware Tools
    • A virtual CD-ROM appears in CentOS
  3. Access the Installation Media

    • Open the CD/DVD drive from the desktop
    • Or access via /run/media/ or /mnt/
  4. Copy Installation Package

    # Create destination directory
    sudo mkdir -p /opt/vmware-tools
    
    # Copy the tarball
    cp /run/media/*/VMwareTools-*.tar.gz /opt/vmware-tools/
  5. Extract the Archive

    cd /opt/vmware-tools
    tar -zxvf VMwareTools-*.tar.gz
  6. Run the Installer

    cd vmware-tools-distrib
    sudo ./vmware-install.pl
  7. Accept Defaults

    • Press Enter to accept all default settings
    • Installation completes automatically
  8. Prerequisites

    • GCC compiler must be installed
    • If missing: sudo yum install gcc make kernel-devel

Configuring Shared Folders

Host-Side Setup:

  1. Create a shared folder on host (e.g., D:\VMShare)
  2. In VMware: VM → Settings → Options
  3. Select "Shared Folders"
  4. Choose "Always enabled"
  5. Add the folder path
  6. Click OK

Guest-Side Access:

  • Shared folders appear in /mnt/hgfs/
  • Navigate: cd /mnt/hgfs/
  • Files are accessible from both host and guest

Note: In production environments, use secure file transfer methods (SCP, SFTP, rsync) instead of shared folders.


Linux Directory Structure: Everything Is a File

Linux employs a hierarchical tree-structured directory system. At the apex sits the root directory (/), from which all other directories branch. This unified structure contrasts sharply with Windows' drive-letter approach.

The fundamental philosophy: "Everything is a file"—hardware devices, processes, sockets, and even system information are represented as files.

Essential Directories Explained

/boot - System Boot Files

Purpose: Contains files required for system startup
Contents:

  • Kernel images (vmlinuz-*)
  • Initial RAM disk (initrd-*)
  • Bootloader configuration (GRUB)
  • System map files

Important: Never delete files from /boot unless you understand the consequences.

/dev - Device Files

Purpose: Hardware device representation
Contents:

  • Disk drives (/dev/sda, /dev/nvme0n1)
  • Terminal devices (/dev/tty*, /dev/pts/*)
  • Random number generators (/dev/random, /dev/urandom)
  • Null device (/dev/null)

Concept: Hardware devices are accessed through file operations.

/bin - Essential User Binaries

Purpose: Critical command executables
Contents:

  • Basic commands (ls, cp, mv, rm)
  • Shell interpreters (bash, sh)
  • File utilities (cat, echo, grep)

Note: Required for single-user mode operation.

/sbin - System Binaries

Purpose: System administration commands
Contents:

  • Network configuration (ifconfig, ip)
  • Disk management (fdisk, mkfs)
  • System control (reboot, shutdown)

Access: Typically requires root or sudo privileges.

/home - User Home Directories

Purpose: Personal directories for regular users
Structure: /home/username/
Contents:

  • User documents and files
  • Application configurations (hidden .* files)
  • Desktop environment settings

Note: Each user has their own isolated home directory.

/root - Root User Home

Purpose: Home directory for the superuser
Distinction: Separate from /home/root (which doesn't exist)
Contents: Root user's personal files and configurations

/lib - System Libraries

Purpose: Shared libraries for system binaries
Contents:

  • Dynamic link libraries (.so files)
  • Kernel modules
  • Firmware files

Analogy: Similar to Windows DLL files.

/lost+found - Recovery Directory

Purpose: Stores recovered files after system crashes
Normal State: Empty or contains few files
After Crash: Filesystem check places recovered fragments here

/etc - Configuration Files

Purpose: System-wide configuration
Contents:

  • Service configurations (/etc/httpd/, /etc/mysql/)
  • User account information (/etc/passwd, /etc/shadow)
  • Network settings (/etc/hosts, /etc/resolv.conf)
  • Startup scripts

Critical: Backup before modifying configuration files.

/usr - User Programs and Data

Purpose: Secondary hierarchy for user applications
Subdirectories:

  • /usr/bin: User command binaries
  • /usr/lib: Library files
  • /usr/local: Locally installed software
  • /usr/share: Architecture-independent data
  • /usr/src: Source code

Analogy: Similar to Windows' "Program Files"

/proc - Process Information (Virtual)

Purpose: Kernel and process information interface
Nature: Virtual filesystem (exists in memory, not disk)
Contents:

  • Process information (/proc/[pid]/)
  • System information (/proc/cpuinfo, /proc/meminfo)
  • Kernel parameters (/proc/sys/)

Warning: Do not modify files in /proc unless you understand the implications.

/srv - Service Data

Purpose: Data for services provided by the system
Contents:

  • Web server content (sometimes)
  • FTP server files
  • Other service-specific data

Usage: Varies by distribution and configuration.

/sys - System Information (Virtual)

Purpose: Kernel device and driver information
Nature: Virtual filesystem (sysfs)
Contents:

  • Device information
  • Driver configurations
  • Power management settings

Warning: Like /proc, modifications can affect system stability.

/tmp - Temporary Files

Purpose: Temporary file storage
Characteristics:

  • Cleared on system reboot (typically)
  • Available to all users
  • Often mounted as tmpfs (RAM-based)

Best Practice: Don't store important data in /tmp.

/media - Removable Media Mount Points

Purpose: Automatic mount points for removable devices
Contents:

  • USB drives
  • CD/DVD drives
  • External hard drives

Behavior: Automatically created when devices are connected.

/mnt - Manual Mount Point

Purpose: Temporary filesystem mounting
Usage:

  • Mount network shares
  • Temporary disk access
  • Manual device mounting

Convention: Create subdirectories for specific mounts (/mnt/usb, /mnt/backup).

/opt - Optional Software

Purpose: Third-party and add-on software
Contents:

  • Commercial applications
  • Large software packages
  • Self-contained applications

Convention: Each application in its own subdirectory (/opt/oracle, /opt/google).

/var - Variable Data

Purpose: Frequently changing data
Contents:

  • Log files (/var/log/)
  • Mail queues (/var/mail/)
  • Print queues (/var/spool/)
  • Website content (/var/www/)
  • Cache files (/var/cache/)

Important: Monitor disk usage—/var can grow significantly.

/selinux - Security-Enhanced Linux

Purpose: SELinux security subsystem
Function: Mandatory access control system
Modes:

  • Enforcing: Security policies actively enforced
  • Permissive: Policies logged but not enforced
  • Disabled: SELinux turned off

Configuration: Managed through /etc/selinux/config


Conclusion: Building Your Linux Foundation

This guide has covered the essential foundations of Linux system installation and directory structure. You've learned how to:

  • Set up a Linux virtual machine safely
  • Configure network connectivity appropriately
  • Install and configure VMware Tools for enhanced integration
  • Navigate the hierarchical directory structure
  • Understand the purpose of each critical directory

Linux mastery begins with these fundamentals. As you continue your journey, you'll discover that this initial investment in understanding pays continuous dividends. The directory structure becomes second nature, command-line operations become intuitive, and the power of Linux becomes an extension of your own capabilities.

Remember: the best way to learn Linux is by using it. Experiment in your virtual machine, break things, fix them, and gradually build confidence. Every system administrator and developer started exactly where you are now—with curiosity and a willingness to learn.

Welcome to the Linux community. Your journey has just begun.