πIntro to Linux

π§ 1. Linux is Open Source and Free
You donβt pay license fees like Windows or macOS.
The source code is open β you can study, modify, and share it.
This makes Linux ideal for learning, developing, and experimenting.
π‘ Example: Ubuntu, Fedora, CentOS, and Debian β all free.
βοΈ 2. Powerful and Stable Operating System
Linux runs servers that stay online for years without reboot.
Very few crashes or slowdowns.
Thatβs why most web servers, cloud systems, and supercomputers use Linux.
π‘ Example: 90%+ of cloud servers on AWS, Azure, GCP run Linux.
π 3. Secure by Design
Fewer viruses and malware than Windows.
User permissions and file ownership protect the system.
Regular security updates from the open-source community.
π‘ Example: Even if malware runs as a normal user, it canβt modify system files without root access.
π§© 4. Perfect for Developers and DevOps Engineers
Comes with all programming tools preinstalled or easily installable:
gcc,python3,git,vim,bash, etc.Most cloud tools and CI/CD pipelines are designed to run on Linux.
π‘ Example: Jenkins, Kubernetes, Docker, Terraform β all Linux-native tools.
π₯οΈ 5. Lightweight and Customizable
You can install a full desktop or a minimal command-line system.
Every component can be replaced or tuned β window manager, shell, even kernel modules.
π‘ Example: Raspberry Pi, routers, and Android phones all run versions of Linux.
π 6. Community and Support
Huge global community.
Thousands of tutorials, Stack Overflow answers, and open-source contributors.
Long-term support versions available (e.g., Ubuntu LTS).
π§ 7. Better for Learning Operating Systems
You can explore how everything works β processes, memory, kernel, file system.
Ideal for students and IT professionals to understand βwhatβs under the hood.β
π‘ Example: Commands like ps, top, df, mount, and /proc show how the system works internally.
β‘ 8. Used Everywhere
| Sector | Linux Usage Example |
| Servers | Web servers, mail servers, DNS, databases |
| Cloud | AWS EC2, Azure VM, Google Cloud Compute Engine |
| Networking | Routers, firewalls, IoT devices |
| Mobile | Android (based on Linux kernel) |
| Cybersecurity | Kali Linux, Parrot OS for ethical hacking |
| Development | Containers, DevOps, AI/ML environments |
π§© Summary
| Reason | Benefit |
| Open Source | Free and transparent |
| Stability | Rarely crashes |
| Security | Strong permissions model |
| Performance | Lightweight and efficient |
| Community | Huge global support |
| Versatility | Runs on servers, phones, clouds |
| Learning | Teaches OS internals clearly |
β In short:
Linux = Free + Secure + Stable + Developer-friendly + Everywhere
Os Architecture

LINUX BOOTING PROCESS

π§ BIOS/UEFI starts β When you power on the computer, the BIOS or UEFI firmware runs first. It checks your hardware (keyboard, RAM, disk, etc.) and finds a bootable device (like hard disk or USB).UEFI is the program built into your motherboard that starts your computer and loads your operating system.
πΏ Bootloader loads (GRUB) β The BIOS/UEFI loads the bootloader (usually GRUB) from the disk. GRUB shows a menu to choose which OS or kernel to boot.
π§ Kernel loads β GRUB loads the Linux kernel (the brain of Linux) into memory. The kernel initializes CPU, memory, and hardware drivers.
π¦ Initramfs runs β A temporary filesystem (initramfs) is loaded to help the kernel mount the real root filesystem (like
/).What is
initramfs?initramfs(Initial RAM Filesystem) is a small temporary root filesystem that gets loaded into memory (RAM) by the Linux kernel during boot.It contains:
Essential drivers (for disk, filesystem, etc.)
Tools and scripts to mount the real root filesystem
Minimal Linux environment used before the main system starts
π Root filesystem mounts β The kernel mounts the actual root filesystem (where
/bin,/etc,/home, etc. are stored).βοΈ Init/Systemd starts β The kernel starts the first process β
initorsystemdβ which controls the rest of the boot process.π§ Services start β Systemd starts all required system services (networking, login, GUI, etc.).
π» Login screen appears β Finally, you get the login prompt or desktop screen, ready to use Linux.
Key files to remember
/boot/grub/grub.conf- GRUB configuration/etc/systemd/system/- systemd unit files/etc/inittab- Init configuration (traditional)/var/log/boot.log- Boot process logs
Linux File Hierarchy Structure

π§© Linux vs Windows β Filesystem Structure Comparison
| Linux Directory | Purpose in Linux | Windows Equivalent | Purpose / Notes in Windows |
/ | Root of the entire Linux file system. Everything starts here. | C:\\ | Root of the primary Windows drive. |
/bin | Essential user binaries (commands needed for all users, like ls, cp, cat). | C:\\Windows\\System32 | Contains core executables (e.g., cmd.exe, system utilities). |
/boot | Bootloader files (kernel, initrd, GRUB). | C:\\Boot and C:\\Windows\\Boot | Stores Windows boot manager and related files. |
/dev | Device files (e.g., /dev/sda for disks, /dev/null). | Device Manager (no real folder) | Windows uses driver abstraction, not files, for devices. |
/etc | System-wide configuration files (text-based). | Windows Registry + C:\\Windows\\System32\\Config | Windows uses Registry instead of plain text configs. |
/home | User home directories. | C:\\Users | Each user has a personal folder (C:\\Users\\Alice). |
/lib | Shared libraries essential for binaries in /bin and /sbin. | C:\\Windows\\System32 | Stores system DLLs. |
/lib64 | 64-bit system libraries. | Same as above (System32 / SysWOW64) | Windows uses separate folders for 32-bit and 64-bit libs. |
/media | Auto-mounted removable media (USB, CD-ROM). | This PC (drives like E:\\, F:\\) | Automatically mounts drives with letters. |
/mnt | Temporary manual mount point for external devices. | Temporary drives like E:\\, F:\\ | Drives are automatically mounted; manual mounting rare. |
/opt | Optional or third-party software (e.g., /opt/google/chrome). | C:\\Program Files | Installed applications. |
/proc | Virtual filesystem showing kernel & process info. | Task Manager / WMIC / PowerShell | Windows shows process info via APIs, not files. |
/root | Home directory for the root (admin) user. | C:\\Users\\Administrator | Adminβs profile directory. |
/run | Temporary runtime data (PID files, sockets). | C:\\Windows\\Temp | Temporary runtime files. |
/sbin | System binaries (administrative commands, e.g., fsck, ifconfig). | C:\\Windows\\System32 | Contains admin tools like diskpart, netsh. |
/srv | Data served by system services (e.g., web/ftp content). | C:\\inetpub (IIS) | Web server content or service data. |
/sys | Virtual filesystem for kernel and hardware interaction. | Device Manager (no folder) | Managed internally by Windows kernel. |
/tmp | Temporary files, cleared on reboot. | C:\\Windows\\Temp | Windows temp files. |
/usr | Secondary hierarchy: user utilities, apps, libraries. | C:\\Program Files and C:\\Program Files (x86) | Installed programs and shared libraries. |
/usr/bin | Non-essential user commands. | C:\\Program Files | User-installed executables. |
/usr/sbin | Non-essential system admin commands. | C:\\Windows\\System32 | Admin tools (services, MMC utilities). |
/usr/local | Locally compiled or manually installed software. | C:\\Program Files (manual installs) | Apps installed outside official installers. |
/var | Variable data β logs, mail, spool, caches. | C:\\ProgramData | Stores logs, caches, databases, etc. |
/var/log | System log files. | Event Viewer (C:\\Windows\\System32\\winevt\\Logs) | Stores event logs. |
/var/mail | User mailbox storage. | Outlook PST or Mail App Data | User-specific mail storage. |
/var/www | Default web server root (Apache/Nginx). | C:\\inetpub\\wwwroot | Default IIS web root. |
/snap | Snap package applications (Ubuntu-specific). | Microsoft Store apps | Isolated, containerized apps. |
/lost+found | Recovered files after filesystem errors. | CHKDSK recovery folder | Windows places recovered files in found.000 folders. |
π§ Summary of Key Differences
| Concept | Linux | Windows |
| Structure | Everything under / | Each drive (C:, D:) separate |
| Configuration | Plain text files | Registry-based |
| Devices | Represented as files under /dev | Managed by Device Manager |
| Case sensitivity | Case-sensitive | Case-insensitive |
| Mounting | Manual/automatic under /mnt or /media | Drive letters assigned automatically |
| Permissions | Owner, group, others (chmod, chown) | NTFS ACLs |
| Logging | /var/log | Event Viewer |
Login to Linux server:
ssh -i demo.pem ubuntu@<public-ip>
sudo apt update ## on ubuntu
sudo yum update ## on redhat, ceentos, amazon linnx
ping <IP>
curl ifconfig.me # Prints public ip
hostname -i # Prints private ip
Working with Files and directories
# Task-1
cd
pwd
cd ~
pwd
cd /
pwd
mkdir dir1
pwd
# Task-2
mkdir -p dir1/dir2/dir3
touch dir1/dir2/dir3/file{1..3}
tree dir1
mv dir1/dir2/dir3/file1 dir1
mv dir1/dir2/dir3/file2 dir1/dir2
tree dir1
mkdir dd
rmdir dd
rmdir dir1
rm -r dir1/dir2/dir3
tree dir1
rm -rf dir1/dir2
tree dir1
rm -rf dir1
tree dir1
# Task-3
mkdir test
cd test
touch file{1..3}.txt
tree
mkdir -p dir1/backup
tree
mv file1.txt file2.txt file3.txt dir1/backup/
tree
# Task-4
Create a world,countries,states hieghrarchy folder structure:
#!/bin/bash
# world_structure.sh
mkdir -p world/{India/{Andhra_Pradesh,Karnataka,Tamil_Nadu,Maharashtra},\\
USA/{California,Texas,New_York,Florida},\\
Australia/{New_South_Wales,Victoria,Queensland}}
echo "Capital: Amaravati" > world/India/Andhra_Pradesh/info.txt
echo "Capital: Austin" > world/USA/Texas/info.txt
echo "Capital: Melbourne" > world/Australia/Victoria/info.txt
ls -R world
# Task-5
touch hotstar
mv hotstar jiohotstar
# Task-5
touch {a..n}.txt
touch report_{1..10}
## Using Wildcards
mv *.txt /home/ubuntu/Documents/ ## Moves all text files in the current folder.
mv report_* /home/ubuntu/reports/ ## Moves all files that start with report_.
# Task-6
touch file1.txt file2.txt
vi file1.txt file2.txt
mv /home/ubuntu/file.txt /home/ubuntu/newfile.txt
Moves the file and renames it in one go.
# Task-7
touch file1.txt file2.txt
# Horizontal Split (one above another)
vim -o file1.txt file2.txt
# Vertical Split (side by side)
vim -O file1.txt file2.txt
Move Between Windows
Press:
Ctrl + w + w # β
This toggles between open windows.
Or use:
Ctrl + w + β β move right
Ctrl + w + β β move left
:wqall # β
Saves and exits all open files


