Skip to Content

Linux File System & Directory Structure with Complete Command Line Basics 


Linux and Bash Scripting Roadmap 

For any DevOps engineers what is Linux and distributions to filesystem navigation and essential commands is very important .Here we will learn step by step every core topic with conceptual clarity .

What is Linux ? 

Linux is a free and open-source operating system (OS) kernel that powers everything from web servers and supercomputers to smartphones and smart TVs. It forms the backbone of cloud infrastructure, DevOps toolchains, modern application deployments, and millions of devices worldwide.

  • What is Linux ? At its core, Linux manages hardware resources, runs programs, and provides an interface between you and your computer's hardware—just like Windows or macOS.
  • Why is Linux important ? Its stability, scalability, versatility, and open-source freedoms make it the go-to platform for developers, cloud engineers, system administrators, and organizations of every size.


History of Linux: From Linus Torvalds to Global Adoption

Linux's history reflects the transformative power of open-source development and community collaboration. 

Linux Kernel Origin

  • Linus Torvalds, while a student at the University of Helsinki in 1991, posted about a new OS kernel—what would become Linux—on an online newsgroup.
  • The Linux kernel was inspired in part by the MINIX OS, and Torvalds’ vision quickly attracted contributions from coders worldwide.


Timeline Snapshot

Year(s) Key Event(s)Description
1991The Birth of LinuxLinus Torvalds announced the development of a free operating system kernel. The first version (0.01) was released in September.
1992Embracing Open SourceThe Linux kernel was relicensed under the GNU General Public License (GPL), allowing free use, modification, and distribution. This decision fostered a global developer community.
1993-1994The Rise of DistributionsDistributions like Slackware and Debian emerged, combining the Linux kernel with GNU utilities. Slackware LinuxDebianRed Hat, and SUSE Linux released their first versions. Linux 1.0 was released in 1994.
1998-2000Enterprise AdoptionCompanies like IBM, Compaq, and Oracle announced their support for Linux. Dell became a major provider of Linux-based systems. Desktop environments like KDE and GNOME emerged.
2000s-PresentExpansion into Diverse DomainsLinux became a cornerstone of: Desktop computing (e.g., Ubuntu), mobile and embedded systems (e.g., Android), cloud computing (e.g., AWS, GCP, Azure), servers (dominating web servers, databases, and enterprise applications), and supercomputing (powering the majority of the world's fastest supercomputers).


History of Linux Distributions

  • Early years: Only source code, targeted at enthusiasts.
  • Distributions (“distros”) such as Debian and Red Hat provided pre-built, user-friendly versions.
  • Today: Over a thousand Linux distributions for desktop, server, cloud, and IoT use cases.

What Are Linux Distributions ?

Linux distribution is a packaged operating system that includes the Linux kernel, system utilities, libraries, desktop environments or server tools, and installation programs.


Popular Linux Distros

  • Ubuntu – User-friendly, extremely popular, supported by Canonical. Great for desktops, servers, and the cloud.
  • Debian – Community-driven, known for stability and breadth of packages.
  • Red Hat Enterprise Linux (RHEL) – Commercial-grade, widely adopted by enterprise environments.
  • Fedora – Cutting-edge features, Red Hat-sponsored, ideal for developers.
  • CentOS or Rocky Linux – Free, enterprise-compatible options after Red Hat changes.
  • Arch Linux – Minimalist, rolling release, favored by advanced users.


Table : Desktop vs. Server Distributions

Use CaseExamplesFeatures
Desktop LinuxUbuntu Desktop, FedoraGUI-focused, multimedia tools, drivers
Server LinuxUbuntu Server, RHEL, CentOSCLI-based, hardened, service-oriented


Desktop vs. Server Linux Editions: What’s the Difference?


  • Desktop Linux: Designed for personal productivity, with graphical user interfaces (GUIs), office software, and multimedia applications.
  • Server Linux: Tailored for hosting websites, databases, application backends. Typically command-line interface (CLI) only, with minimal extra packages for security and stability.


FeatureDesktop EditionServer Edition
InterfaceGUI (Gnome, KDE, Xfce, etc.)CLI; GUI usually not installed
Software BundlesOffice, browser, multimedia appsServer software (web, DB, SSH)
UsagePersonal computers, laptopsWeb, DB, cloud servers
OptimizationUser experience, visual effectsPerformance, security, uptime


Server-Grade Linux vs Desktop GUI

  • Server-grade Linux is lean, less prone to vulnerabilities, and can run for years without reboots.
  • Desktop Linux prioritizes usability, plug-and-play hardware, and graphical utilities.


How to Install Linux in Virtual Machines


Linux Virtual Machine


Here's a general overview of how to install Linux (using Ubuntu as an example) on a virtual machine using VirtualBox : 

  1. Download and Install VirtualBox :
    • Visit the VirtualBox website.
    • Download the appropriate package for your host OS (Windows, macOS, etc.).
    • Install VirtualBox, following the on-screen instructions.
  2. Download the Linux ISO :
    • Download the ISO file for the Linux distribution you wish to install (e.g., Ubuntu).
    • The latest LTS version of Ubuntu can be downloaded from the Ubuntu website.
  3. Create a new virtual machine in VirtualBox:
    • Open VirtualBox Manager.
    • Click "New" to create a new VM.
    • Give your VM a name (e.g., "Ubuntu VM").
    • Select "Linux" as the type and the appropriate version (e.g., "Ubuntu (64-bit)").
    • Allocate sufficient RAM for your VM (e.g., 1024MB or higher, depending on your system's resources).
    • Create a virtual hard disk by choosing "Create a virtual hard disk now".
    • Select "VDI (VirtualBox Disk Image)" as the hard disk file type.
    • Choose "Dynamically allocated" for storage on the physical hard drive.
    • Set the maximum size for the disk (e.g., 20 GB or more).
  4. Install the Linux operating system :
    • Double-click the VM you just created to start it.
    • When prompted, select the downloaded Linux ISO as the startup disk.
    • Follow the on-screen instructions to install Linux within the VirtualBox window.
    • This process will involve selecting language, keyboard layout, time zone, creating a username and password, and possibly choosing between a normal or minimal installation.
    • The installation will take some time to complete.
  5. Restart and Log In:
    • Once the installation finishes, restart the VM.
    • After restarting, you can log into your newly installed Linux system.


    After these steps, you will have a functional Linux virtual machine running within VirtualBox, allowing you to explore and use Linux without affecting your host OS.

    So Why use a Virtual Machine ?

    • No impact on your main OS
    • Isolate practice environments
    • Revert changes with snapshots
    • Try multiple distros in parallel


    Understanding the Linux Filesystem- An In-Depth Guide for DevOps Engineers



    Key Filesystem Types in Linux

    Linux supports several filesystem types, each with its unique features and benefits. The most important ones includes :

     

    • ext4 (Fourth Extended Filesystem) : The default and most widely used filesystem for Linux. It's known for its reliability and balanced performance for general use cases like desktops and servers.
      • Features: Used for data integrity, large file and volume size support, backward compatibility with ext2 and ext3, delayed allocation for improved performance and reduced fragmentation, and online defragmentation.
      • Benefits: Very stable and compatible across Linux distributions.


    • XFS: A high-performance, 64-bit filesystem designed for scalability and handling large files, often used in servers and high-load environments.
      • Features: Excellent parallel I/O capabilities, extent-based allocation, delayed allocation, and online resizing and defragmentation.
      • Benefits: Ideal for large files, databases, and high-throughput applications.
      • Limitations: Can be less efficient with numerous small files.


    • Btrfs (B-tree Filesystem): A modern filesystem emphasizing data integrity, fault tolerance, and ease of administration. It's considered an alternative or successor to ext4 for some use cases.
      • Features: Copy-on-write mechanism, snapshots and subvolumes, built-in RAID support, data integrity checksums, and online resizing.
      • Benefits: Excellent for data integrity, backup, and advanced storage management.
      • Limitations: Its RAID 5 and 6 implementations are still experimental, and it may have performance overhead with some workloads due to the Copy-on-Write mechanism.


    • ZFS (Zettabyte Filesystem): Originally developed for Solaris, ZFS is a powerful and feature-rich filesystem, although not natively included in the Linux kernel due to licensing issues.
      • Features: Combines filesystem and volume management, end-to-end data integrity with checksums, advanced RAID-Z configurations, snapshots, and optional features like deduplication and compression.
      • Benefits: Extremely high data integrity, excellent scalability, and built-in redundancy.
      • Limitations: Requires substantial memory, and its licensing (CDDL) can be a factor for Linux users.

     

    When choosing a filesystem for your Linux system, consider your specific needs and priorities, such as workload type, performance requirements, data integrity needs, and desired features

    Essential Linux file navigation commands for new users

    The following are the most important commands for navigating the Linux filesystem:


    pwd – Print Working Directory

    Displays the absolute path of your current location in the file system.

    pwd
    

    Example Output: /home/rahul

    📁 ls – List

    Lists the contents of a directory.

    • ls : Basic list
    • ls -l : Detailed view (permissions, owner, size, etc.)
    • ls -a : Shows hidden files
    • ls -lrta :  Helpful when you want to quickly identify the most recently changed or created files, as they will appear at the end of the list. 
    • Combine flags : ls -la

    ls command used in a Linux terminal to list the files and directories in the current working directory. The output shows file names without detailed information, useful for quick navigation and directory overview.

    📂 cd – Change Directory

    Used to move between directories.

    • cd directory_name – Go into a subdirectory
    • cd /absolute/path/ – Move using full path
    • cd .. – Move up one level
    • cd ~ or cd – Go to home directory
    • cd - : Return to previous directory


    mkdir – Make Directory

    Creates a new directory.

    mkdir my_folder
    

    🗑️ rmdir – Remove Directory

    Deletes an empty directory.

    rmdir old_folder
    

    📄 cp – Copy

    Copies files or directories.

    • Copy a file : cp file.txt /target/path/ or cp  folder/file.txt  /target/path/
    • Copy a directory recursively : cp -r folder/  /target/path/

    mv – Move / Rename

    Moves or renames files and directories.

    • Move a file : mv file.txt /target/ or mv target/file.txt  /target/
    • Rename : mv folder1/oldname.txt  folder2/newname.txt

    rm – Remove

    Deletes files or directories.

    • Remove file: rm file.txt
    • Remove directory recursively: rm -r folder/ (Use with caution)

    touch – Create Empty File

    Creates a new, empty file.

    touch newfile.txt
    

    🔎 find – Search for Files and Directories

    Searches using various filters like name, size, or modified time.

    basic syntax : find [path] [options] [expression]

    • Find by name :
      find . -name "thisfile.txt"
      
    • Find all .jpg files in /home:
      find /home -name "*.jpg"
      
    • Search by user and time:
      find /home -user randomperson -mtime 6 -iname "*.db"
      
    • Find large files (>250MB) :
      find / -size +250M
      

    grep – Search Inside Files

    Searches for text patterns in files.

    basic syntax for the grep command in Linux and Unix is : grep [options] pattern [file...]

    • Simple search:
      grep "search term" file.txt
      
    • Recursive search in directory:
      grep -r "term" /path/to/dir/
      
    • Case-insensitive:
      grep -i "term" file.txt
      

    📘 man – Manual Pages

    Displays documentation for commands.

    man ls
    

    Learn what each command does and how to use its flags effectively.

    This collection of commands is foundational for Linux users for DevOps tasks. 

    Important Linux Interview Question

    boot process in Linux

    The boot process in Linux can be summarized as follows :

    1. The computer hardware is powered on, and the BIOS or UEFI firmware takes control.
    2. The firmware initializes the hardware, including the CPU, memory, and other peripherals.
    3. The bootloader is loaded from the MBR into memory.
    4. The bootloader takes control and displays a menu or configuration options for selecting an operating system (if applicable).
    5. The bootloader loads the operating system’s kernel and necessary files into memory from the boot device.
    6. The operating system starts execution

    Bootloader ensures a smooth transition from hardware initialization to the startup of the operating system.

    Linux Booting Process


    what are some common causes of bootloader failure in linux ?

    Some common causes of bootloader failure in Linux include :

    1. Misconfiguration : Incorrect configuration of the bootloader can cause it to fail to load the kernel. This can happen if the bootloader is not configured to point to the correct location of the kernel image.
    2. Corrupted bootloader : The bootloader can become corrupted due to various reasons such as a power outage, hardware failure, or a software bug. This can cause the bootloader to fail to load the kernel.
    3. Corrupted kernel image : The kernel image can become corrupted due to various reasons such as a software bug, hardware failure, or a power outage. This can cause the bootloader to fail to load the kernel.
    4. Hardware failure : Hardware failures such as a failing hard drive or memory module can cause the bootloader to fail to load the kernel.
    5. User error : User errors such as accidentally deleting or modifying critical system files can cause the bootloader to fail to load the kernel.