Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
33 views51 pages

Linux Notes

The document provides a comprehensive overview of the history and development of Linux and Ubuntu, tracing its origins from UNIX in the 1960s to the creation of the Linux kernel by Linus Torvalds in 1991. It highlights the significance of the GNU Project in forming a complete open-source operating system and details the features and variations of popular Linux distributions, particularly Ubuntu. Additionally, it explains the architecture of Linux, emphasizing its modular design and the roles of different components.

Uploaded by

cre8tivepalette
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views51 pages

Linux Notes

The document provides a comprehensive overview of the history and development of Linux and Ubuntu, tracing its origins from UNIX in the 1960s to the creation of the Linux kernel by Linus Torvalds in 1991. It highlights the significance of the GNU Project in forming a complete open-source operating system and details the features and variations of popular Linux distributions, particularly Ubuntu. Additionally, it explains the architecture of Linux, emphasizing its modular design and the roles of different components.

Uploaded by

cre8tivepalette
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

Introduction and History of Linux n Ubuntu

1. Introduction and History of Linux n Ubuntu

Origins: The Development of UNIX


The history of Linux begins with the origins of UNIX, an operating system that fundamentally shaped modern
computing. The roots of UNIX date back to the mid-1960s, when Bell Labs, in collaboration with General Electric and
the Massachusetts Institute of Technology (MIT), began developing a complex multi-user operating system called
Multics (Multiplexed Information and Computing Service). Although ambitious, the Multics project failed to meet
expectations and was eventually discontinued by Bell Labs in 1969.

Despite the project's cancellation, two Bell Labs researchers—Ken Thompson and Dennis Ritchie—believed in the
concept of a time-sharing, multi-tasking operating system. They began working on a new, simpler OS as a side
project. Using a PDP-7 minicomputer, they created the first version of UNICS (later stylized as UNIX)—a play on the
name Multics, suggesting a more "uniplexed" system.

The real breakthrough came when Ritchie, also a pioneer in programming language design, created the C
programming language, and UNIX was rewritten in C in the early 1970s. This was revolutionary: it made UNIX
more portable and easier to modify, helping it spread across academic and research institutions.

By the mid-1970s, UNIX Version 6 had become widely used in universities, and it soon evolved into several different
proprietary and academic variants. Some of the most notable "flavors" of UNIX that emerged include:

● IBM AIX – A version of UNIX developed for IBM's enterprise systems.

● Sun Microsystems Solaris – Known for its robustness in enterprise and network environments.

● HP-UX – Hewlett-Packard's UNIX offering, used mostly in business and server systems.

● macOS – Although now quite distinct, Apple’s macOS has UNIX roots through BSD (Berkeley Software
Distribution), making it UNIX-compliant today.

UNIX's modularity, stability, and open philosophy (especially through early access to its source code) made it a
foundational influence on future operating systems, including Linux.

The Birth of Linux: Linus Torvalds and the Open Source Revolution
Fast forward to the early 1990s: UNIX had become well-established but was fragmented across commercial versions,
many of which were costly. At this time, Linus Torvalds, a computer science student at the University of Helsinki in
Finland, wanted to explore and experiment with UNIX-like systems. He started using MINIX, a lightweight UNIX-like
system developed by Andrew Tanenbaum for educational purposes. However, MINIX had limitations—it was not truly
free, and its development was tightly controlled.

Driven by curiosity and frustration, Linus decided to create his own operating system kernel. On August 25, 1991, he
famously announced his project in a newsgroup post and released the first version of the Linux kernel—a monolithic
kernel written in C. Just a few weeks later, on September 17, 1991, the first public version (0.01) was released.

What made Linux different was that Linus released it under the GNU General Public License (GPL), which meant
that anyone could view, use, modify, and share the source code freely. This opened the door to global collaboration,
and developers worldwide began contributing.

The Role of GNU and Free Software


Parallel to Torvalds’ efforts, Richard Stallman had already launched the GNU Project in 1983 with the goal of
creating a completely free Unix-like operating system. The GNU Project developed essential system components
such as compilers, libraries, and shell utilities. However, it lacked a functioning kernel.

When Linux (the kernel) was combined with the existing GNU software stack, the result was a complete, free, and
open-source operating system often referred to as GNU/Linux. This marked a turning point in software development
and the open-source movement, emphasizing user freedom, collaboration, and transparency.

What is Linux?
Linux, in technical terms, refers specifically to the kernel—the core component of the operating system that interacts
directly with the hardware, manages system resources, and enables software applications to run. However, in
common usage, “Linux” often refers to entire Linux distributions (distros), which are complete operating systems
built around the Linux kernel and bundled with a wide range of tools and software.

Key features of Linux include:

● Multitasking and multi-user capabilities

● Security through strong permission and user models

● Stability and performance, making it ideal for servers

● Customizability, due to its open-source nature

● Broad hardware support, from embedded devices to supercomputers

Popular Linux distributions include Debian, Fedora, Arch Linux, Red Hat Enterprise Linux (RHEL), and of course,
Ubuntu.

Introduction to Ubuntu
Ubuntu is one of the most widely used and beginner-friendly Linux distributions. It was first released in October
2004 by a UK-based company called Canonical Ltd., founded by entrepreneur Mark Shuttleworth. Ubuntu is based
on Debian, another major Linux distribution known for its stability and vast package repository.

What set Ubuntu apart was its emphasis on:

● Ease of use – Ubuntu offered a modern, graphical desktop environment (initially GNOME, later Unity, then
back to GNOME), making Linux more accessible to the average user.

● Regular release cycles – A new version of Ubuntu is released every six months, with Long-Term Support
(LTS) versions released every two years and supported for five years or more.

● Community and support – Ubuntu has a vast global community, with extensive documentation and forums
for troubleshooting and learning.

● Pre-installed software – Ubuntu comes with essential applications like Firefox, LibreOffice, and multimedia
tools, making it usable out of the box.

● Enterprise readiness – Canonical offers professional support and cloud-based tools, making Ubuntu popular
in server and cloud environments, especially with platforms like AWS and Microsoft Azure.

Ubuntu is available in multiple variants tailored for specific use cases:


● Ubuntu Desktop – For personal computers and laptops

● Ubuntu Server – Optimized for server environments

● Ubuntu Core – A minimal version for IoT and embedded devices

● Ubuntu Cloud – For cloud-native development and deployment


Linux Distribution
1. Linux Distribution

A Linux distribution—often called a distro—is a complete, ready-to-use operating system built around the Linux
kernel. While the kernel is the core of the operating system responsible for managing hardware and system
resources, it alone is not sufficient for daily use. A Linux distribution packages the kernel with a variety of additional
software to create a fully functional system.

These components typically include:

● System utilities (for file management, network configuration, etc.)

● Package managers (for software installation and updates)

● Desktop environments (e.g., GNOME, KDE, XFCE for graphical user interfaces)

● Compilers, interpreters, and development tools

● Office and multimedia applications

● Security tools and system monitoring software

Instead of requiring users to build a working OS environment from the ground up, distributions offer a pre-configured
and tested collection of tools that cater to specific use cases—such as general desktop use, programming, server
management, multimedia production, cybersecurity, or enterprise IT.

Each Linux distro has its own philosophy, target audience, and design goals, ranging from user-friendly systems
like Ubuntu to advanced, highly customizable distributions like Arch Linux.

The GNU General Public License (GPL)


The GNU General Public License (GPL) is a critical element in the success of Linux and open-source software in
general. Created by the Free Software Foundation (FSF) as part of the GNU Project, the GPL defines the terms
under which software can be used, modified, and distributed.

Key aspects of the GPL:

● Freedom to use the software for any purpose

● Freedom to study and modify the source code

● Freedom to share the software with others

● Copyleft requirement: If you modify and distribute GPL-licensed software, your modified version must also
be licensed under the GPL, keeping it open and accessible to others

Linux Package Formats: .deb and .rpm


Linux distributions use package managers to install, update, and remove software efficiently. These tools rely on
package files—compressed archives that contain application binaries, metadata, and installation scripts.

Two major package formats dominate the Linux ecosystem:

1. .deb (Debian Package Format)


● Used by: Debian and Debian-based distributions, including Ubuntu, Linux Mint, Kali Linux, and others.

● Package managers:

○ APT (Advanced Package Tool) – Handles installation, upgrades, and dependency management.

○ dpkg – A low-level tool used internally by APT for installing .deb packages.

2. .rpm (Red Hat Package Manager Format)

● Used by: Red Hat Enterprise Linux (RHEL), Fedora, CentOS, AlmaLinux, and openSUSE.

● Package managers:

○ DNF (Dandified YUM) – Modern tool used by Fedora and newer Red Hat systems.

○ YUM – Older tool still used in some systems for backward compatibility.

○ RPM – The original utility used to manage .rpm packages.

Popular Linux Distributions


Below are some of the most widely used and respected Linux distributions, each serving different audiences and use
cases.

1. Ubuntu

● Target Audience: Beginners, students, general desktop users, and businesses


● Why It's Popular:
○ User-friendly, intuitive interface
○ Large community and commercial support from Canonical Ltd.
○ Regular release cycles and Long-Term Support (LTS) editions
● Key Features:
○ Simple graphical installer
○ Extensive software repositories
○ Pre-installed tools for productivity and media
○ Cloud and server versions widely used in DevOps and web hosting

2. Debian

● Target Audience: Advanced users, developers, and system administrators


● Why It's Popular:
○ Known for rock-solid stability and conservative package updates
○ The foundation for many other distributions (e.g., Ubuntu, Kali Linux)
● Key Features:
○ Strong community governance
○ Large, well-tested software repository
○ Emphasis on free and open-source software principles

3. Linux Mint

● Target Audience: Beginners and users transitioning from Windows


● Why It's Popular:
○ Designed for ease of use, particularly for those unfamiliar with Linux
○ Polished desktop environments like Cinnamon that resemble Windows
● Key Features:
○ Pre-installed multimedia codecs and essential software
○ Stable and performance-optimized
○ Focus on usability over cutting-edge software

4. Red Hat Enterprise Linux (RHEL)

● Target Audience: Businesses, IT professionals, and enterprise environments


● Why It's Popular:
○ Commercial support and training options
○ Certified by major hardware and software vendors
○ Common in data centers and critical business systems
● Key Features:
○ Subscription-based support from Red Hat
○ Extended support lifecycles and security updates
○ Integration with enterprise tools like Ansible and Red Hat Satellite

5. SUSE Linux Enterprise / openSUSE

● Target Audience: Enterprises, system administrators, developers


● Why It's Popular:
○ SUSE provides a flexible platform with powerful system administration tools
○ openSUSE (community version) and SUSE Linux Enterprise Server (SLES) for businesses
● Key Features:
○ YaST (Yet another Setup Tool) – A comprehensive configuration tool
○ Strong focus on security, scalability, and automation
○ Versatile installation options and great documentation

6. Kali Linux

● Target Audience: Cybersecurity professionals, penetration testers, and ethical hackers


● Why It's Popular:
○ Tailored for digital forensics, vulnerability assessment, and security testing
○ Maintained by Offensive Security
● Key Features:
○ Comes pre-loaded with hundreds of hacking, forensics, and network tools (e.g., Metasploit, Nmap,
Wireshark
○ Customizable for different hardware platforms, including ARM devices
○ Regularly updated for emerging threats and tools
Ubuntu Desktop vs Server
Ubuntu Desktop vs Server

Ubuntu, one of the most widely used Linux distributions, is available in different editions tailored to meet specific
needs. The two most common editions are Ubuntu Desktop and Ubuntu Server. While they share the same core
system and are based on the same Linux kernel, they are optimized for very different use cases.
Ubuntu Desktop
Ubuntu Desktop is designed primarily for personal computing. It targets general users, students, and developers
who work on laptops and desktop computers. It provides a Graphical User Interface (GUI) and comes bundled with
a set of pre-installed applications that make it ready for use out of the box.

🔑 Key Features of Ubuntu Desktop:

● Graphical Interface (GUI): Ubuntu Desktop ships with the GNOME desktop environment (as of recent
versions), providing a user-friendly and modern visual experience.

● Pre-installed Applications:
○ Firefox – Web browser
○ LibreOffice – Office suite (word processing, spreadsheets, presentations)
○ Rhythmbox, Totem, etc. – For media playback
○ Ubuntu Software Center – For installing additional software easily

● Plug-and-Play Support:
○ Recognizes and configures peripherals like printers, USB drives, Bluetooth devices, webcams,
and external monitors automatically.

● Multi-language and Accessibility Options: Great for users around the globe with diverse needs.

● Ideal Use Cases:


○ Daily personal computing
○ Light software development
○ Internet browsing and communication
○ Media playback and productivity tasks

💽 Types of Ubuntu Desktop:

1. Live Version:
○ Boots directly from a USB or DVD without modifying your hard drive.
○ Useful for testing Ubuntu before installing.
○ Also used for recovery and troubleshooting.

2. Install Version:
○ A full installation setup that installs Ubuntu onto your system's hard drive.
○ Offers customization options during setup (disk partitioning, language, etc.).

Ubuntu Server
Ubuntu Server is a version of Ubuntu specially designed for deployment in data centers, enterprise environments,
and cloud platforms. Unlike the desktop version, it does not include a graphical interface by default, relying
instead on the Command-Line Interface (CLI) to conserve resources and improve performance.

🔑 Key Features of Ubuntu Server:

● ⚙️Command-Line Based:
○ Optimized for speed, efficiency, and headless operation (no GUI).
○ Suitable for remote access and scripting.

● ⚙️Built-In Server Applications:


○ Web Servers: Apache, Nginx
○ Database Servers: MySQL, PostgreSQL
○ File Sharing: Samba, NFS
○ Remote Management: OpenSSH for secure remote access

● ⚙️Remote & Cloud Management:


○ Easily managed with automation tools like:
■ SSH – Secure remote shell access
■ Ansible – IT automation and configuration management
■ MAAS (Metal as a Service) – For provisioning and managing bare-metal servers

● ⚙️Lightweight and Minimal:


○ Uses fewer system resources (RAM, CPU) compared to desktop editions.
○ Ideal for running headless systems like cloud VMs, containers, and physical servers without
monitors.

💽 Types of Ubuntu Server:

1. Standard Server Install:


○ Installs a barebones Ubuntu Server system with no GUI.
○ Suitable for both physical and virtual machines.
○ Offers choices during installation for server roles (e.g., SSH server, LAMP stack).

2. Ubuntu Server Live Installer:


○ A more modern and user-friendly interface for installation.
○ Replaces the older text-based installer for recent versions.
○ Offers better hardware compatibility and automation features.

3. Cloud Images:
○ Pre-configured, lightweight Ubuntu Server instances optimized for cloud environments.
○ Available on public clouds such as:
■ Amazon Web Services (AWS)
■ Google Cloud Platform (GCP)
■ Microsoft Azure

○ Features:
■ Fast boot times
■ Auto-scaling
■ Cloud-init support for automation
Linux Architecture
Linux Architecture

The architecture of Linux refers to the structured design and interaction between different
components of the operating system. Like most modern OSes, Linux follows a layered
architecture where each layer communicates with the one below or above it. This modular design
contributes to Linux’s portability, stability, scalability, and security.

At its core, Linux architecture consists of four main layers:

1. Hardware
2. Kernel
3. Shell
4. Applications

Each layer plays a unique role in ensuring the smooth operation of the system.

1. Hardware Layer

This is the physical foundation of any computing system. It includes all physical components that
perform computation, input/output (I/O) tasks, storage, and networking.
Key Hardware Components:

● CPU (Central Processing Unit):


○ Executes instructions and performs all computational tasks.
○ The Linux kernel is CPU-agnostic, meaning it is designed to support a wide variety
of CPU architectures (e.g., x86, ARM, RISC-V).

○ Manages process scheduling, multi-threading, and instruction execution.

● RAM (Random Access Memory):


○ Serves as primary memory, temporarily storing data and instructions used by the
CPU.
○ The Linux kernel handles memory allocation, paging, swapping, and ensures that
active processes receive the memory they need.

● Input/Output Devices:
○ Includes keyboards, mice, touchpads, monitors, printers, USB drives, etc.
○ Linux uses device drivers to communicate with hardware, allowing the kernel to
abstract hardware operations from the application level.
○ Linux supports a wide range of I/O devices, thanks to its extensive and modular
driver ecosystem.

2. Kernel Layer

The kernel is the core component of Linux. It directly interacts with the hardware and manages
system resources such as CPU time, memory, disk access, and device input/output.
Main Responsibilities of the Linux Kernel:

● Process Management:
○ Manages the creation, scheduling, and termination of processes.
○ Ensures multitasking and fair CPU time distribution.

● Memory Management:
○ Allocates and deallocates memory to processes.
○ Uses virtual memory and paging to optimize performance.

● Device Management:
○ Interacts with all hardware through device drivers.
○ Offers plug-and-play support via the udev subsystem.

● File System Management:


○ Manages how data is stored and retrieved on disk.
○ Supports multiple file systems (ext4, Btrfs, XFS, etc.).

● Network Management:
○ Handles communication between systems using protocols like TCP/IP.
○ Supports IPv4, IPv6, firewalling, VPN, and more.

● Security and Access Control:


○ Manages user permissions, system calls, and access to system resources.
○ Features like SELinux, AppArmor, and cgroups enhance security and isolation.

3. Shell Layer

The shell serves as a bridge between the user and the kernel. It interprets user commands and
translates them into system-level actions.
Types of Shells in Linux:

● Command-Line Shells:
○ Popular shells include Bash, Zsh, Ksh, and Fish.
○ Allows scripting and automation of tasks.
● Graphical Shells:
○ Part of the desktop environment (e.g., GNOME Shell).
○ Provide visual user interfaces for interacting with the OS.
Shell Functions:

● Accepts commands from users


● Initiates program execution
● Enables environment customization through configuration files like .bashrc and .zshrc
● Allows scripting for automation and task scheduling

4. Application Layer (User Space)

This is the topmost layer where users interact with the operating system through applications
and software tools.
Examples of Linux Applications:

● Web Browsers: Firefox, Chromium


● Media Players: VLC, Rhythmbox
● Office Suites: LibreOffice
● Development Tools: VS Code, GCC, Python, Java

These applications run in user space, meaning they are isolated from the kernel and cannot
directly access hardware or system memory without passing through system calls.

System Components in Linux Architecture


In addition to the layered model, Linux architecture includes a number of essential components
that support the overall system operation.

1. Bootloader

● A program responsible for starting the Linux OS after the system is powered on.
● Loads the Linux kernel into memory and hands over control.
● Common Linux bootloaders:
○ GRUB (GRand Unified Bootloader) – most commonly used
○ LILO (Linux Loader) – older bootloader, less common today
○ BURG – a graphical bootloader built on GRUB

2. Init System:

● Handles the initialization of the system after booting.


● Starts background services (daemons) and mounts file systems.
● Types of init systems:
○ System V init (SysV) – older, script-based
○ Upstart – used in older Ubuntu versions
○ systemd – modern, parallelized, and widely adopted init system in most distributions

3. Server Components:

● Linux excels in server environments due to its performance and reliability.


● Popular server software includes:
○ Apache – Web server
○ Nginx – Lightweight web server and reverse proxy
○ MySQL / MariaDB / PostgreSQL – Database servers
○ OpenSSH – Secure remote login and file transfer
● These servers enable Linux to be used for:
○ Web hosting
○ Cloud computing
○ File and print services
○ Database management

4. Desktop Environment:

● Provides a graphical interface for users who prefer GUI over CLI.
● A desktop environment includes:
○ Window Manager (e.g., Mutter, KWin)
○ File Manager (e.g., Nautilus, Dolphin)
○ System Settings
○ Dock or Panel
● Popular Linux desktop environments:
○ GNOME – Default for Ubuntu, clean and modern
○ KDE Plasma – Highly customizable and feature-rich
○ Cinnamon – Designed for Windows users (used in Linux Mint)
○ MATE and XFCE – Lightweight, great for older machines
Shell
Shell

In a Linux-based operating system, the shell plays a critical role as the interface between the user and the
operating system kernel. It accepts commands from the user, interprets them, and communicates with the kernel to
execute the desired operations.

Think of the shell as a command interpreter—a middle layer that converts human-readable instructions into
machine-level tasks handled by the system. When a user launches a terminal window or logs into a system via SSH,
they are typically greeted by a command-line shell.

● Accepts user input from the keyboard or script


● Parses and interprets commands
● Passes valid commands to the Linux kernel for execution
● Displays output or errors back to the user
● Supports scripting for task automation

🔀 Types of Shells in Linux


Linux shells are broadly categorized into two types:

1. Command-Line Shells (CLI)


A command-line shell is a text-based interface where users type commands manually. It is preferred by advanced
users, system administrators, and developers due to its speed, power, and scripting capabilities.

🔹 Key Functions of CLI Shells:

● File and directory management (ls, cd, rm, etc.)


● Process control (ps, kill, top)
● System monitoring
● Writing and executing shell scripts (.sh files)
● Package management and software installation
● Task automation via crontab or scripts

🧾 Popular Command-Line Shells (with Comparison):


Shell Description Notable Features

Bourne Shell One of the earliest UNIX shells, Lightweight and widely compatible;
(sh) developed by Stephen Bourne at basis for scripting standards
Bell Labs.

Bourne Again Default shell in most Linux distros, Command history, auto-completion,
Shell (bash) created as a free replacement for scripting support, job control
sh.
C Shell (csh) Introduced C-style syntax; created at Better suited for C programmers;
the University of California, supports aliases and job control
Berkeley.

Korn Shell Developed by David Korn; combines Advanced scripting, better


(ksh) features of sh and csh. performance, interactive features

Z Shell (zsh) A modern shell with features from Highly customizable, plugins/themes
(Oh My Zsh), better tab completion
bash, ksh, and tcsh.

💡 Why Use CLI Shells?

● Lightweight (no graphical overhead)


● Ideal for remote management (e.g., via SSH)
● Powerful scripting capabilities
● Offers precise control over system tasks

2. Graphical User Shells (GUI)


A graphical shell is part of the desktop environment that provides a visual interface for users to interact with the
system using peripheral devices such as a mouse, keyboard, and touchscreen.

Unlike the CLI, GUI shells use windows, icons, menus, and pointer devices to perform operations—ideal for users
who are unfamiliar with or prefer not to use command-line tools.

🔹 What Graphical Shells Provide:

● Desktop interface (taskbars, menus, file explorers)


● Window management (minimize, maximize, switch)
● Integrated applications (web browsers, text editors)
● System settings and configuration tools

Popular Graphical Shells and Desktop Environments:


Shell / DE Description Key Highlights

GNOME GNU Network Object Model Clean and modern UI, accessibility
Environment. Default in Ubuntu and support, extensible
others.

KDE Feature-rich desktop with extensive Widgets, advanced settings,


Plasma customization options. animations, lightweight in recent
versions

Cinnamon Developed by Linux Mint, user-friendly Familiar for Windows users, good for
and traditional in layout. beginners

MATE A continuation of GNOME 2, lightweight Great for older hardware or users


and stable. seeking simplicity

XFCE Lightweight desktop environment. Minimalist, fast, ideal for low-


resource systems
Kernel
Kernel

The kernel is the core of the operating system and it is the foundation of other software that works
on top of it. It handles and hides all the complexity and underlying modules of the hardware. It is
the foundational layer on which another system operates. Let’s see some of the functions of the
kernel:
● Device Management: Manages all the device hardware parts including the device drivers,
input-output operation, and peripheral devices.
● Manage Resources: The kernel manages the processes of the CPU and all the peripheral
devices and acts as the bridge between the resources and processes.
● Memory Management: Kernel mainly manages memory and provides some benefits
● System calls: For managing the file operation, memory control, and process control kernel
receives system calls to perform requested services.
● Performation optimization: Balancing all the resources with the memory, optimizes the
system performance and boosts the system efficiency. It also schedules the task according
to the level of priority.
Types of Kernels in OS Architecture

1. Monolithic
2. Microkernel
3. Hybrid
4. Nano kernel
5. Exo kernel
Linux includes a monolithic kernel which makes this OS the most stable and fast

1. Monolithic Kernel

In a monolithic kernel, all essential operating system services (like memory management, file
system, device drivers, and process scheduling) run in a single large block of code in the same
memory space (kernel space).

● Advantages: Fast performance due to direct communication between components.

● Disadvantages: Difficult to maintain or debug; a bug in one part can crash the whole
system.

● Examples: Linux, Unix, BSD

2. Microkernel

A microkernel keeps only the most essential functions (like basic inter-process communication
and CPU scheduling) in kernel space. Other services, such as device drivers and file systems, run
in user space.

● Advantages: More stable and secure; system crashes are less likely to affect the entire OS.

● Disadvantages: Slower due to context switching between user and kernel space.
● Examples: Minix, QNX, L4, Mach (used in early macOS)

3. Hybrid Kernel

A hybrid kernel combines features of both monolithic and microkernels. It runs some services in
kernel space (for performance) and others in user space (for modularity and stability).

● Advantages: Balances performance and stability.

● Disadvantages: Can become complex and bloated over time.

● Examples: Windows NT (used in Windows 10/11), XNU (used in macOS), modern Linux
(arguably has hybrid traits)

4. Exokernel

An exokernel is an experimental type of kernel that provides minimal abstraction over hardware. It
allows applications to directly manage hardware resources with minimal intervention from the OS.

● Advantages: Offers maximum efficiency and flexibility to applications.

● Disadvantages: Complex for application developers; not widely used in commercial


systems.

● Examples: ExOS (MIT project)

5. Nanokernel (optional / niche)

A nanokernel is even smaller than a microkernel and only includes the most basic hardware
abstractions, often used as a base for other kernels or hypervisors.

● Used In: Real-time systems, embedded environments, or virtualization platforms.


File System Hierarchy
File System Hierarchy

The Linux File Hierarchy Structure, or Filesystem Hierarchy Standard (FHS), defines the
directory layout and contents in Unix-like operating systems. Maintained by the Linux Foundation,
FHS ensures consistency across distributions.

In Linux, all files and directories are organized under a single root directory /, regardless of
whether they reside on physical or virtual storage. Some directories may only appear if specific
subsystems (e.g., the X Window System) are installed.

While many of these directories are common across UNIX systems, the descriptions below follow
the FHS used specifically in Linux.

Important Directories in Linux

1. / (Root)
○ The top-level directory in the file system.
○ All other directories branch from this root.
Only the root user can write to this directory.
○ /root is the root user's personal home directory — different from /.
2. /bin
○ Contains essential binary executables needed by all users.
○ Includes common commands like ls, cp, mv, grep, and ping.
3. /boot
○ Stores files required to boot the system, such as the kernel and GRUB configuration.
○ Examples: vmlinuz, initrd.img, grub/.
4. /dev
○ Contains device files that act as interfaces to hardware.
○ Includes block devices (e.g., /dev/sda1) and character devices (e.g., /dev/tty1).
5. /etc
○ Stores system configuration files and scripts.
○ Includes startup/shutdown scripts and user-related settings.
○ Example: /etc/passwd, /etc/hosts.
6. /home
○ Contains personal directories for each non-root user.
○ Example: /home/anshu, /home/kishlay.
7. /lib
○ Holds shared libraries required by programs in /bin and /sbin.
○ Examples: ld-2.31.so, libc.so.

8. /media
○ Temporary mount point for removable media like USB drives and CDs.
Example: /media/cdrom, /media/usb.
9. /mnt
○ A generic mount point used by system administrators for mounting filesystems
temporarily.
10. /opt
○ Stores third-party applications and their data/configuration.
○ Example: /opt/google/chrome/.
11. /sbin
○ Contains system administration binaries, often requiring root privileges.
○ Example commands: fdisk, ifconfig, reboot, iptables.
12. /srv
○ Stores service-related data, such as websites and FTP files.
Example: /srv/www, /srv/ftp.
13. /tmp
○ Temporary file storage used by programs during execution.
○ Files are typically deleted at reboot.
14. /usr
○ Secondary hierarchy for user applications and data.
○ Subdirectories include:
■ /usr/bin: User commands not essential for booting.
■ /usr/sbin: Admin tools not required during boot.
■ /usr/lib: Libraries for /usr/bin and /usr/sbin.
■ /usr/local: Locally compiled programs (e.g., from source).
■ /usr/src: Kernel source and header files.
15. /proc
○ A virtual (pseudo) filesystem that provides real-time information about system and
processes.
○ Examples:
■ /proc/meminfo: Memory usage.
■ /proc/uptime: System uptime.
■ /proc/[pid]: Info about a specific process.

Navigation in Linux
Navigating the Linux file system is done using terminal commands. Here are some basic navigation
commands:

● pwd – Displays the present working directory.


● ls – Lists files and folders in the current directory.
● cd <directory> – Changes directory.
○ Example: cd /home/anshu navigates to the user "anshu"'s home directory.
● cd .. – Moves up one directory level.
● cd ~ or simply cd – Returns to the current user’s home directory.
● ls -l – Lists files in long format, showing permissions, owner, size, and modification time.
● ls -a – Shows all files, including hidden ones (those beginning with a dot .).
● tree – Displays directory structure in a tree-like format (may require installation).
● find and locate – Help search for files within the filesystem.

Understanding the structure and navigation commands is crucial for working effectively in a Linux
environment.
File and Directory Operations
File and Directory Operations

1. Introduction to Linux File System

● Linux uses a hierarchical file system structure starting from the root directory (/), where all files and
directories reside.
● Everything in Linux is treated as a file, including devices, directories, and even processes.
● Managing files and directories efficiently is essential for any Linux user or administrator.

2. File and Directory Operations

● Listing Files (ls):


The ls command is used to display files and directories in the current location.
Options:
○ ls -l shows detailed information including permissions, ownership, size, and modification date.
○ ls -a lists all files including hidden ones (those starting with a dot .).
● Changing Directory (cd):
Moves the user to a different directory.
Examples:
○ cd /home/user moves to a specific folder.
○ cd .. moves one level up in the directory tree.
○ cd ~ moves to the home directory.
● Print Working Directory (pwd):
Displays the absolute path of the current directory.
● Creating Files (touch):
Creates a new empty file or updates the timestamp of an existing file.
● Creating Directories (mkdir):
Used to create new directories.
Example: mkdir projects creates a directory named “projects”.
● Removing Directories (rmdir):
Deletes empty directories only.
● Copying Files and Directories (cp):
Copies files or folders from one place to another.
The -r (recursive) option copies entire directories including their contents.
● Moving or Renaming (mv):
Moves files or directories to a new location or renames them.
● Deleting Files and Directories (rm):
Deletes files.
For directories, rm -r is required to remove the directory and all its contents recursively.
The -f (force) option forces deletion without asking for confirmation.
Caution: Using rm -rf can permanently delete data without any warning.
● Searching for Files (find):
Searches the file system for files or directories matching specific criteria like name, type, or modification date.
Example: find /home -name "*.txt" finds all .txt files in /home.

3. File Permissions in Linux

● Linux supports multiple users, so it uses a permission system to control access to files and directories.
● User Categories:
○ Owner: The user who owns the file.
○ Group: A set of users grouped together; the file has a group owner.
○ Others: All other users on the system.
● Types of Permissions:
○ Read (r): Permission to view the contents of a file or list a directory.
○ Write (w): Permission to modify or delete the contents of a file or directory.
○ Execute (x): Permission to run a file as a program or enter a directory.
● Permissions are shown using ls -l, which displays a 10-character string:
○ The first character indicates file type (- for file, d for directory).
○ The next nine characters represent permissions in three groups of three: user, group, others.
Example: -rwxr-xr-- means the owner can read, write, and execute; group can read and execute;
others can only read.

4. Changing Permissions and Ownership

● Changing Permissions (chmod):


The chmod command modifies permissions using either symbolic notation (u, g, o for user, group, others) or
numeric notation.
Numeric permissions are calculated by adding:
○ Read = 4
○ Write = 2
○ Execute = 1
For example, chmod 755 file sets permissions to rwxr-xr-x.
● Changing Ownership (chown):
The chown command changes the owner and/or group of a file or directory.
Example: chown user:group file assigns ownership to a user and group.

5. Importance of Permissions

● Proper permissions prevent unauthorized users from reading or modifying sensitive data.
● Permissions ensure system security and stability, especially on multi-user or server environments.
● Misconfigured permissions can lead to security vulnerabilities or accidental data loss.

6. Additional Security Layers

● Beyond traditional permissions, Linux supports Access Control Lists (ACLs) for more fine-grained control.
● Security frameworks like SELinux provide mandatory access controls to further restrict program and user
capabilities.
Linux Booting Porcess
Linux Booting Porcess

When you turn on a Linux system, it goes through several steps to become ready for you to use. Here's
the complete process explained in simple words, from pressing the power button to seeing the login
screen.

🔹 Step 1: BIOS / UEFI – Turns on the Computer

BIOS (Basic Input Output System) or UEFI (Unified Extensible Firmware Interface on modern systems)
is built into your motherboard.

It performs:

● POST (Power-On Self Test) to check hardware (RAM, keyboard, storage, etc.).
● Finds the bootable device, such as your hard drive or SSD.
● Hands over control to the bootloader, typically via the MBR or EFI partition.
🧠 Think of BIOS/UEFI as the computer's gatekeeper, ensuring all hardware is okay before
handing off control.

🔹 Step 2: MBR – Loads the Bootloader

MBR (Master Boot Record) is the first sector (only 512 bytes!) of your hard disk.

It contains:

● A tiny program that locates and starts the bootloader (usually GRUB).
● The partition table, which tells how your disk is divided.

🧠 The MBR acts like a signpost — it knows where the boot loader is and points the system to it.

Note: On UEFI systems, the bootloader is located in the EFI partition instead of using MBR.

🔹 Step 3: GRUB – Loads the Kernel

GRUB (Grand Unified Bootloader) is the program that:


● Shows a boot menu (so you can select the OS or kernel version),
● Loads the Linux kernel into memory,
● Loads initrd or initramfs, a temporary root filesystem with essential drivers.

🧠 GRUB is like a menu waiter, bringing the kernel and helping it start with the right options.

🔹 Step 4: Kernel – Starts the Heart of Linux

The Linux kernel is the core of the OS. It:

● Loads essential drivers (keyboard, disk, USB, etc.),


● Mounts the initramfs (temporary root filesystem),
● Starts the first user-space process: init or systemd.

🧠 The kernel connects hardware with software, making your system functional.

🔹 Step 5: Init / systemd – Starts Services

The first process started by the kernel is called init (PID 1). Most modern distros use systemd instead.

It:

● Starts background services (networking, sound, display manager),


● Determines the system target or runlevel,
● Manages dependencies between services (only systemd does this efficiently).

🧠 systemd uses unit files to manage services and boot targets.

🔹 Step 6: Runlevels (0 to 6) – System Modes

A runlevel tells the system what mode to boot into.

Runlev Name Description


el
0 Halt Shuts down the system

1 Single-user For maintenance (no network)


mode
2 Multi-user No networking (rarely used)

3 Full multi-user Text-based interface with networking

4 Undefined Can be customized by users

5 Graphical Multi-user with GUI (e.g., Ubuntu


mode desktop)
6 Reboot Restarts the system

🧠 On systemd-based systems, runlevels are replaced by targets:

● runlevel 3 → multi-user.target
● runlevel 5 → graphical.target

🔹 Step 7: Login – You Can Use the System


Once all services start and the correct target is reached:

● If using GUI: a display manager like GDM, LightDM, or SDDM shows the graphical login
screen.
● If using text mode: a login prompt appears in the terminal (TTY).

After login, your desktop environment or shell session starts, and you can now use the Linux
system!
User Managment
User Management

User Management in Linux


User management is a core function of Linux system administration. It involves creating, modifying, and deleting user
accounts, setting permissions, and assigning group access to maintain system security and multi-user functionality.

Importance of User Management

● Controls access to system resources.


● Ensures only authorized users can perform specific tasks.
● Supports a multi-user environment, from personal systems to large-scale servers.
● Helps in tracking and auditing user activities.
Prevents security risks due to unauthorized or careless usage.

🆔 User Identification in Linux

Each user in Linux is assigned a User ID (UID) and associated information stored in system files like /etc/passwd.

UID Range Description

0 Root (superuser)

1 – 999 System/service
accounts
1000+ Normal user accounts

● Each user also belongs to a Group ID (GID) which defines group-based access.

👤 Types of Users in Linux


1. Root User (Superuser):
○ Has complete system access.
○ Can perform critical tasks like installing packages, managing users, and editing system files.
2. Regular User:
○ Can perform everyday tasks like creating files, running applications, and browsing the web.
○ Cannot modify system-level files without permission.
3. Sudo User:
○ A regular user with administrative privileges granted using the sudo command.
○ Can execute specific admin tasks without full root access.
4. System/Service Users:
○ Created by the system to run services like www-data, mysql, etc.
○ Do not log in or interact with users.
5. Guest Users:
○ Temporary users with limited access.
○ Used for short-term or restricted usage; data is not saved permanently.

👥 User Groups
Linux uses groups to simplify permission management for multiple users.

1. Primary Group:
○ Every user has one default group (usually same as their username).
○ Files created by the user are assigned to this group.
2. Secondary Groups:
○ Users can be part of additional groups.
○ Useful for granting shared access to resources like software, devices, or directories.
Example:
To add a user to a group:

bash
CopyEdit
sudo usermod -aG groupname username

Common User Management Commands


Task Command Example

List all users awk -F':' '{ print $1 }'


/etc/passwd
View user ID info id username

Add a new user sudo useradd username

Assign password sudo passwd username

Modify user info sudo usermod [options] username

Delete a user sudo userdel -r username

🧾 User Configuration Files

● /etc/passwd: Stores user details (username, UID, GID, home directory, shell).
● /etc/shadow: Stores encrypted passwords.
● /etc/group: Contains group information.

⚠️Common Issues in User Management


Issue Solution Example

Forgotten Password sudo passwd username

Locked Account sudo usermod -U username

Incorrect File Permissions chmod and chown to correct access


rights
Misconfigured Groups Add to group using usermod -aG

Privilege Escalation Risk Use sudo visudo to control sudo


access
Broken Config Files Edit /etc/passwd safely with sudo
vipw
User Account Management Commands in Linux
🔹 Basic User Commands:

1. List all users:


awk -F':' '{print $1}' /etc/passwd – Lists all usernames from the /etc/passwd file.

2. Get user ID:


id username – Displays the UID and GID of the given user.

3. Add a user:
useradd username – Creates a new user account.

4. Assign a password:
passwd username – Sets or changes the password for a user.

5. View user configuration:


cat /etc/passwd – Shows details like username, UID, GID, home directory, and shell.

🔧 Modify User Information:


1. Change user ID:
usermod -u new_uid username – Changes the UID of an existing user.

2. Change group ID:


usermod -g new_gid username – Changes the primary group ID of a user.

3. Change login name:


usermod -l new_name old_name – Renames the user’s login name.

4. Change home directory:


usermod -d /new/home username – Sets a new home directory for the user.

5. Delete a user:
userdel -r username – Deletes the user and their home directory.

⚠️Common User Management Issues:


1. Forgotten passwords:
passwd username – Resets the password to restore user access.

2. Account lockouts:
usermod -U username – Unlocks a locked user account.

3. Security vulnerabilities:
apt update && apt upgrade – Keeps the system up to date and secure.

4. Permission errors:
chmod / chown – Fixes file or folder access issues.

5. Group membership issues:


usermod -aG group username – Adds a user to a specific group.

6. Privilege escalation risks:


visudo – Safely edits the sudoers file to control admin rights.

7. Misconfigured user files:


vipw / vigr – Safely edits /etc/passwd and /etc/group files.

https://www.geeksforgeeks.org/linux-unix/user-management-in-linux/
Group Managment
Group Managment

Group management in Linux helps in organizing users into logical units, allowing administrators to assign
permissions and control access to files and system resources efficiently.

🔸 Types of Groups in Linux


1. Primary Group
○ Automatically created when a new user is added.
○ The group has the same name and ID as the user.
○ It is the default group for any files the user creates.
2. Secondary Group
○ Created manually to provide additional access rights.
○ A user can belong to multiple secondary groups.
○ Helps in managing shared access for teams or services.

⚙️Group Configuration Files

● /etc/group – Lists all groups, their names, IDs, and members.


● /etc/gshadow – Stores encrypted group passwords and administrative details.

Common Group Management Commands


Task Command Description

Create a new groupadd Adds a new group with a unique Group ID.
group group_name
Example groupadd Group1 Creates a group named Group1.

🔐 Set or Change Group Password

● Command: gpasswd group_name


● Allows assigning a password to a group for shared authentication.

Example:
gpasswd Group1

📂 View Group Password File

● Command: cat /etc/gshadow


● Displays encrypted passwords and group admin information (not for casual viewing).

➕ Add User to a Group


1. Replace Existing Groups (Dangerous):
○ usermod -G group_name username
○ Warning: This removes the user from all other secondary groups.

Example:
usermod -G group1 John_Doe

2. Safely Add to Additional Groups:


○ usermod -aG group_name username
○ Appends the user to the group without affecting existing memberships.
Example:
usermod -aG group1 John_Doe

👥 Add Multiple Users to a Group

● Command: gpasswd -M user1,user2,user3 group_name


● Adds multiple users to a group at once.

Example:
gpasswd -M Person1,Person2,Person3 Group1

❌ Remove a User from a Group

● Command: gpasswd -d username group_name


● Removes the user from the group but not from the system.

Example:
gpasswd -d Person1 Group1

Delete a Group

● Command: groupdel group_name


● Deletes a group from the system; users revert to their primary groups if not in any others.

Example:
groupdel Group1
File Permission and Security
File Permission and Security

Linux File Permissions and Security


Linux file permissions form the foundation of the system’s security model. They define who can read, write, or
execute files and directories, ensuring that only authorized users or processes can access sensitive data. You can
modify these permissions using the chmod command.

🔧 Common chmod Examples


bash
CopyEdit
chmod +rwx filename # Adds read, write, and execute permissions
chmod -rwx directoryname # Removes all permissions
chmod +x filename # Grants executable permission
chmod -wx filename # Removes write and execute permissions

1. The Three Basic Permissions


Every file or directory has three types of permissions:

● Read (r): View the contents of a file or list the contents of a directory.

● Write (w): Modify a file or add/delete files within a directory.

● Execute (x): Run a file as a program/script or access a directory.

Letter Meaning

r Read the file

w Write or modify

x Execute (if applicable)

2. Ownership and Permission Groups


Permissions are assigned to three categories of users:

● User (Owner): The creator of the file.

● Group: A set of users sharing the same group.

● Others: Everyone else on the system.

These are reflected in the permission string as:


text
CopyEdit
--- --- ---
rwx rwx rwx
user group other

User, Group, and Others in Linux


Referenc Class Description
e
u User Owner of the file/directory

g Group Users in the file’s group

o Other All other users


s
a All Applies to user, group,
others

3. How to Check File Permissions in Linux


🔍 Method 1: ls -l
bash
CopyEdit
ls -l NarX.txt

Example Output:

csharp
CopyEdit
-rw-r--r-- 1 user group 46 Apr 14 16:37 NarX.txt

Breakdown:

● -: It's a file (d means directory).

● rw-r--r--: Permission string (user, group, others).

● user, group: Owner and group.

● 46: File size in bytes.

● Apr 14 16:37: Last modified date and time.

● NarX.txt: File name.


🔍 Method 2: namei
Shows each component in the file path and its permissions.

bash
CopyEdit
namei -l /path/to/your/file

🔍 Method 3: stat
Gives detailed file metadata.

bash
CopyEdit
stat hoops

Example Output:

yaml
CopyEdit
File: hoops
Size: 2210 Blocks: 8 IO Block: 4096 regular file
Access: 2024-11-18 10:50:56.000000000 +0000
Modify: 2024-11-18 10:50:56.000000000 +0000
Change: 2024-11-18 10:50:56.000000000 +0000

4. Changing Permissions in Linux


🔁 Symbolic Notation

Use chmod with symbolic notation to add/remove/set permissions.

Examples:

bash
CopyEdit
chmod o+x xyz.txt # Add execute to others
chmod ugo-rwx xyz.txt # Remove all permissions for everyone
chmod ug+rw,o-x abc.mp4 # Add read/write to user & group; remove exec from
others
chmod ug=rx,o+r abc.c # Set read+exec for user/group, read for others

🔢 Octal Notation
Permissions are represented using numbers:
Permissio Binary Octal
n
--- 000 0

--x 001 1

-w- 010 2

-wx 011 3

r-- 100 4

r-x 101 5

rw- 110 6

rwx 111 7

Examples:

bash
CopyEdit
chmod 777 file.txt # rwx for user, group, others
chmod 755 file.txt # rwx for user, rx for group and others
chmod 435 file.txt # r for user, wx for group, rx for others

5. Understanding Permission Strings


For example: rw- r-x r--

Sectio Meaning
n
rw- User can read/write

r-x Group can


read/execute
r-- Others can only read

6. Special Permissions in Linux


🛡 setuid (Set User ID)
Runs the program with the file owner’s privileges.

bash
CopyEdit
chmod u+s program
🛡 setgid (Set Group ID)
Files: Run as group.
Directories: New files inherit the directory's group.

bash
CopyEdit
chmod g+s directoryname

🛡 Sticky Bit
Allows only the file’s owner to delete it in a shared directory.

bash
CopyEdit
chmod +t directoryname

7. Changing Ownership
🔧 chown: Change file owner/group
bash
CopyEdit
chown user:group file.txt

🔧 chmod: Modify permissions


bash
CopyEdit
chmod 755 file.txt
File Permisision n Security Option 2
In Linux, file permission and security help control who can read, write, or execute files and directories. Every file has
three types of permissions for three types of users:

User Categories:

1. Owner (User) – Creator of the file.

2. Group – Users in the same group.

3. Others – Everyone else.

🔐 Permission Types:

● r (read) – View contents.

● w (write) – Modify contents.

● x (execute) – Run the file as a program.

You can view permissions using the ls -l command.

Example:

🔧 Important Commands:

1. chmod (Change Mode):


Used to change file permissions.
Example: chmod 755 file.txt
This gives: owner full access, group and others read & execute.

2. chown (Change Owner):


Changes the owner or group of a file.
Example: chown user:group file.txt

3. umask (User Mask):


Sets default permissions for newly created files.
For example, a umask of 022 means new files will have 755 permissions (full for owner, read-execute for
others).
Text Editor and File viewing
Text editor and file viewing

Text editors are used to write or edit text files. Linux provides both command-line and graphical text editors.

🔹 1. Command-Line Text Editors:

● nano:

○ Simple and beginner-friendly.

○ Opens directly in the terminal.

○ Basic shortcuts (e.g., Ctrl+O to save, Ctrl+X to exit).

○ Command: nano file.txt

● vim (Vi Improved):

○ Advanced and powerful.

○ Has two modes: insert mode (for writing) and command mode (for editing and saving).

○ Command: vim file.txt

○ Useful shortcuts: i (insert), :w (save), :q (quit), :wq (save and quit)

🔹 2. Graphical Text Editors (GUI):

● Examples: gedit, kate, leafpad

● Easy to use with mouse and menus.

● Installed by default in desktop environments like GNOME or KDE.

● Command: gedit file.txt (opens editor window)

📄 File Viewing Commands in Linux:


These commands help users to read the contents of text files without editing them.

🔹 1. cat:

● Displays the entire content of a file at once.

● Best for small files.

● Command: cat filename.txt

🔹 2. less:

● Opens file one screen at a time.


● Allows scrolling up and down.

● Use / to search, q to quit.

● Command: less filename.txt

🔹 3. more:

● Similar to less but only scrolls forward.

● Command: more filename.txt

🔹 4. head:

● Shows the first 10 lines of a file by default.

● Command: head filename.txt

● Show specific number of lines: head -n 20 filename.txt

🔹 5. tail:

● Shows the last 10 lines of a file.

● Useful for monitoring logs.

● Command: tail filename.txt

● Live updates: tail -f /var/log/syslog

📌 Additional Points:
● These tools are lightweight and fast.

● Essential for system administrators, developers, and programmers.

● Support shell scripting, configuration file editing, and log file monitoring.

● Combine commands with pipes (|) for advanced usage.


Example: cat file.txt | grep "error"

You might also like