Linux: Architecture, Distributions, and Command-Line Management
Linux Origins and Core Concepts
- Historical Background: Linux is an operating system created by Linus Torvalds in 1991. At the time of its inception, Torvalds was a graduate student in Finland.
- Core Features:
- UNIX Inspiration: The architecture and design philosophies were heavily inspired by the UNIX operating system.
- Multi-user Support: Allows multiple users to access and use system resources simultaneously.
- Multi-tasking: Capable of running multiple processes or applications at once.
- Stability and Security: The system is designed with a primary focus on maintaining uptime and protecting data integrity.
- Open-Source Philosophy: Most importantly, Linux is open-source. This means the source code is freely available for anyone to view, modify, and distribute. This openness has established Linux as the backbone of modern computing infrastructure, powering everything from consumer devices to global data centers.
Scalability: From Supercomputers to SOCs
- Supercomputing Scale: India’s Param Ganga supercomputer represents a medium-sized supercomputer powered by Linux.
- Nodes: Contains 312 nodes.
- Processing Power: Utilizes approximately 15,000 CPUs.
- Power Consumption: Operates at a peak of 50.0 to 100.0MW.
- Miniature Scale: VoCore’s System on a Chip (SOC) demonstrates Linux's efficiency on small hardware.
- Components: Includes a CPU and an LED.
- Memory: Features 128MB of RAM.
- Power Consumption: Operates at a peak of 200mA.
Linux Distributions and Flavors
- Definition of a Distribution (Distro): A Linux distro is a package that combines the Linux kernel with specific software, libraries, and configurations. There are hundreds, if not thousands, of unique distributions currently in existence.
- Variants and Flavors: Some distributions offer variants (often called "flavors") that change the user interface (UI), styling, or configuration while keeping the same core system.
- Kubuntu: A version of Ubuntu that uses the KDE desktop environment instead of the default Gnome.
- Xubuntu: A version of Ubuntu using the Xfce desktop, which is lightweight and designed specifically for older hardware.
- Ubuntu Kylin: A variant specifically localized and tailored for users in China, including specific applications and language settings.
- Tracking Distributions: The website Distrowatch is the primary resource for tracking and monitoring the various Linux distributions available.
- Notable Distributions:
- Kali Linux: Known for its focus on offensive security, penetration testing, and digital forensics.
- Ubuntu (Debian-based): A widely popular distribution geared toward desktop users and general end-users.
- Red Hat Linux (RHEL): Highly focused on the enterprise and corporate sectors.
- Hannah Montana Linux: Explicitly cited as "a mistake" in the lecture materials.
Linux on Windows: Windows Subsystem for Linux (WSL)
- WSL Overview: A compatibility layer that enables users to run Linux natively on Windows 10 and Windows 11.
- Key Characteristics:
- Integrates Linux command-line utilities and tools directly into the Windows environment.
- Operates without the overhead of a traditional virtual machine or the inconvenience of dual-booting.
- Grants full access to standard Linux command-line tools such as
bash, grep, and awk.
- Access Method: Accessible directly via the
wsl command in Windows. - Supported Distributions: WSL supports numerous distributions, including Ubuntu, Kali, and Fedora.
The Linux Filesystem Structure and Standards
- Hierarchy: Linux uses a tree-like, hierarchical directory structure.
- Root Directory: The top level of the hierarchy is called "root" and is represented by a single forward slash:
/. - Navigation Shortcuts:
- Current Directory: Represented by a single dot:
. - Parent Directory: Represented by two dots:
..
- Basic Commands:
cd: Change the current directory to a different location.pwd: Print the current working directory path.ls: List the files and directories located in the current directory.
- The "Everything is a File" Philosophy:
- Files and Directories: Standard data containers and folders.
- Devices: Represented as files in the directory
/dev. For example, /dev/input handles keyboards and /dev/sda1 represents hard disks. - Processes: Active programs are represented in the
/proc directory.
- Filesystem Hierarchy Standard (FHS): Most distributions follow the FHS to ensure consistency across the ecosystem. This ensures that critical directories like
/home (the location of user home directories) remain in the same place across different distros.
File Permissions and Ownership
- Ownership System: Linux implements a UNIX-style ownership model for all directory and file entries.
- Core Management Commands:
ls -l: Generates a long-format file listing to show ownership and permission modes.chown: Used to change the owner and the group association of a specific file.chmod: Used to modify who is permitted to read, write, or execute a file.
- Permission Marker Layout (from
ls -l results):- Column 0: Type marker where
d indicates a directory, - indicates a file, and l indicates a symbolic link. - Columns 1-3: Permissions set for the User (Owner).
- Columns 4-6: Permissions set for the Group.
- Columns 7-9: Permissions set for Others (World).
- Permission Codes:
r: Permission to Read.w: Permission to Write.x: Permission to Execute.
- Example Interpretation: In a listing where columns 1-3 are
rw-, columns 4-6 are rw-, and columns 7-9 are r--, the owner and group have read/write access while all other users have only read access.
Process Management and System Monitoring
- Process Control:
- Force Termination: Use the
kill -9 $PID command to stop a process by its Process ID (PID). - Manual Exit: Pressing
^c (Ctrl+c) will exit a process currently running in the foreground of a terminal.
- Process Viewing: Use the command
ps to see running processes.- Arg
-a: Displays processes for all users on the system. - Arg
-u: Displays detailed usage columns including: user, pid, %cpu, %mem, vsz, rss, tty, state, start, time, and command. - Arg
-x: Includes processes that are not attached to a terminal.
- System Monitoring Tools:
- Disk Usage: Use
df -h -total to see human-readable disk consumption and total system totals. - System Usage: Use
top to view real-time system usage and a dynamic list of active processes. - Network Monitoring: Use
netstat -tlp to display processes currently listening for TCP connections.