Introduction to Linux and Unix
1. What is an Operating System (OS)?
An Operating System (OS) is a software that:
- Manages computer hardware and system resources such as CPU, memory, disk storage, and input/output devices.
- Acts as an interface between users and the computer hardware, enabling interaction and allowing users to perform useful tasks.
2. What is Unix?
Definition:
Unix is a family of multitasking, multiuser operating systems originally developed in the 1960s.
Key Characteristics:
- Designed for servers, workstations, and mainframes.
- Known for stability, security, and performance.
Popular Unix-Based Operating Systems:
- Oracle Solaris
- FreeBSD
- HP-UX
- IBM AIX
- Apple macOS – one of the most popular desktop operating systems today.
Historical Development of Unix:
- 1960s: Original Unix OS was developed at AT&T Bell Labs.
- Initially created for the PDP-7 computer.
- 1970s: Rewritten in the C programming language, making it portable across different hardware platforms.
- Late 1970s: Berkeley Software Distribution (BSD) was developed by UC Berkeley.
- Added new features and tools.
- Laid the foundation for future systems like macOS.
3. What is Linux?
Definition:
Linux is a family of Unix-like operating systems. When people mention Linux, they usually refer to a specific distribution or flavor of Linux.
Purpose of Linux:
Developed to provide a free, open-source alternative to Unix.
Key Features of Linux:
- Free and Open Source:
- Anyone can view, modify, and distribute the source code.
- Encourages transparency and collaborative development.
- Security:
- High security due to open-source nature and community scrutiny.
- Multi-user:
- Supports multiple users accessing the system simultaneously.
- Multitasking:
- Capable of running multiple applications and jobs at the same time.
- Portability:
- Runs on a wide range of hardware platforms — from embedded systems to supercomputers.
4. Historical Development of Linux
1980s: GNU Project
- Developed at MIT.
- Stands for “GNU’s Not Unix”.
- Aimed to create a free, open-source version of Unix system tools.
- However, lacked a kernel.
1991: Birth of the Linux Kernel
- Created by Linus Torvalds.
- Linus announced his project via a famous email, describing his efforts to develop a free, open-source Unix-like kernel.
- The kernel is the core component of an OS, responsible for communication between software and hardware.
1992: Merging GNU and Linux
- Developers realized the potential of combining the GNU tools with the Linux kernel, leading to the birth of full-fledged Linux-based operating systems.
1996: Tux the Penguin
- Created by Larry Ewing, a computer scientist.
- Adopted by Linus Torvalds as the official Linux mascot.
5. Current Use Cases of Unix and Linux
Unix (e.g., macOS):
- Widely used on millions of Apple devices worldwide.
- Based on BSD Unix.
Linux:
- Powers billions of servers around the world, serving the modern internet.
- Increasingly popular among developers as a desktop OS (e.g., Ubuntu).
Common Use Cases for Linux Today:
- Mobile Devices:
- Android uses a Linux-based kernel.
- Billions of smartphones run on Linux-powered Android.
- Supercomputing:
- Used in clusters of high-performance computing systems.
- Dominates the field of scientific and engineering computation.
- Enterprise & Cloud Data Centers:
- Millions of servers run Linux for hosting web services, databases, and cloud infrastructure.
- Personal Computers:
- Many users install Linux for learning or daily use.
- Popular distributions include Ubuntu, Fedora, Debian, Linux Mint, etc.
6. Summary
✅ Define what an Operating System (OS) is and its role.
✅ Understand the history and evolution of Unix.
✅ Explain the origins of Linux and how it relates to Unix.
✅ List the key features of Linux: free/open-source, secure, multi-user, multitasking, and portable.
✅ Recognize the modern-day usage of Linux in mobile devices, servers, supercomputers, and PCs.
Overview of Linux Architecture
1. Introduction to Linux System Layers
The Linux system is structured into five distinct layers, each with a specific role in ensuring the smooth operation of the system.
The Five Layers of Linux Architecture:
- User Interface (UI)
- Application Layer
- Operating System (OS) Layer
- Kernel Layer
- Hardware Layer
2. Layer-by-Layer Breakdown
1. User Interface (UI)
- Role: Allows users to interact with the system using input devices like keyboard or mouse.
- Types:
- Graphical User Interface (GUI) – Found in desktop versions, similar to Windows or macOS.
- Command Line Interface (CLI) – Used for direct command execution via terminal.
Example: You can use a web browser (application) through the GUI to send an email or a music player to listen to a song.
2. Application Layer
- Definition: Contains software tools and programs that allow users to perform tasks.
- Includes:
- System tools (e.g., compilers)
- Programming languages
- Shells (command interpreters like Bash)
- User applications (web browsers, text editors, games)
These applications communicate with the OS to execute commands and access resources.
3. Operating System (OS) Layer
- Role: Manages critical system functions to ensure stability and performance.
- Key Responsibilities:
- Assigning software access to users
- Detecting and handling errors
- Managing files and directories
- Ensuring system health and resource allocation
This layer sits on top of the kernel and provides high-level management services.
4. Kernel Layer
- Definition: The core component of the Linux operating system.
- Function: Acts as a bridge between applications and hardware using system calls.
- Starts at boot and remains in memory until shutdown.
- Four Key Functions:
- Memory Management – Allocates and manages RAM.
- Process Management – Controls running processes and CPU time.
- Device Drivers – Enables communication with hardware components.
- Security Management – Ensures secure system operations.
The kernel is the lowest-level software in the system and has full control over it.
5. Hardware Layer
- Definition: Physical or electronic components of the computer.
- Includes:
- Central Processing Unit (CPU) – Executes instructions.
- Random Access Memory (RAM) – Temporary storage during runtime.
- Storage Devices – Hard drives, SSDs, etc., for persistent data.
- Input/Output Devices – Keyboard, mouse, screen, USB drives.
The kernel interacts directly with this layer to manage resources and run applications.
3. Linux Filesystem Structure
Overview
- The Linux filesystem organizes all files and directories in a tree-like structure.
- The root directory, represented by
/
, is the topmost level.
Key Directories in the Filesystem
Directory | Purpose |
---|---|
/ (Root) | Top-level directory containing all other directories. |
/bin | Essential user binary files (commands like ls , cp ). |
/usr | User programs and utilities (e.g., applications). |
/home | Personal working directories for users (e.g., /home/user ). |
/boot | Files needed to boot the system (kernel, bootloader config). |
/media | Mount point for removable media (USB drives, CDs). |
/etc | Configuration files for system and applications. |
/var | Variable data such as logs, caches, and spool files. |
/tmp | Temporary files used by applications and the OS. |
/dev | Device files representing hardware components. |
/lib | Shared libraries required by binaries in /bin and /sbin . |
Each file and directory has access rights assigned for security and proper usage.
4. Summary
✅ The five layers of a Linux system: UI, Applications, OS, Kernel, and Hardware.
✅ The role of each layer in enabling user interaction, application execution, and hardware communication.
✅ The structure of the Linux filesystem, including key directories and their purposes.
Visual Representation (Simplified)
[User Interface]
↓
[Applications]
↓
[Operating System]
↓
[Kernel]
↓
[Hardware]
Quick Recap Table
Layer | Description | Example |
---|---|---|
User Interface | How users interact with the system | GUI (desktop), CLI (terminal) |
Application Layer | Tools and programs for tasks | Web browser, text editor |
Operating System | Manages system health and jobs | Process scheduling, error detection |
Kernel | Core of the OS; communicates with hardware | Memory & process management |
Hardware | Physical components | CPU, RAM, storage, input/output devices |
1. Introduction to Text Editors in Linux
Text editors are essential tools for writing, modifying, and managing code or configuration files in a Linux environment.
Two Main Categories of Text Editors:
Type | Description |
---|---|
Command-line text editors | Operate directly in the terminal. Useful for remote servers and scripting environments. |
GUI-based text editors | Offer a graphical interface with menus and toolbars. Ideal for desktop users. |
2. Popular Command-Line Text Editors
1. GNU nano
- Description: A beginner-friendly, modeless editor.
- Features:
- Undo/Redo
- Search and Replace (with regex)
- Syntax highlighting
- Automatic indentation
- Line numbers
- Multiple file buffers
To open or create a file:
nano filename.txt
Basic nano Commands (Use Ctrl + [Key])
Command | Function |
---|---|
Ctrl + G | Get Help |
Ctrl + W | Search for text (“Where Is”) |
Ctrl + O | Write (Save) the file |
Ctrl + X | Exit nano |
Ctrl + K | Cut a line |
Ctrl + U | Paste a line |
2. vi / vim
- vi: One of the original Unix text editors.
- vim: Improved version of vi; stands for Vi IMproved.
- Modes:
- Insert Mode: For typing/editing text.
- Command Mode: For navigating, saving, quitting, etc.
To start editing a file:
vim filename.txt
Basic vim Workflow
- Open file → starts in Command Mode
- Press
i
→ switch to Insert Mode - Edit text
- Press
Esc
→ return to Command Mode - Save and exit:
:w
→ write/save changes:q
→ quit:wq
→ save and quit:q!
→ quit without saving
Tip: Vim has a steep learning curve but is extremely powerful once mastered.
3. Popular GUI-Based Text Editor
gedit
- Default editor in GNOME desktop environments.
- Designed for simplicity and ease of use.
- Comes preinstalled on many Linux distributions.
Key Features of gedit:
- Integrated file browser
- Undo/Redo functionality
- Search and Replace (supports regular expressions)
- Plugin support via
gedit-plugins
- Syntax highlighting for programming languages
Ideal for beginners or anyone who prefers a visual interface.
4. Other Notable Text Editors
emacs
- One of the oldest open-source projects still maintained.
- Available in both CLI and GUI modes.
- Extremely customizable and feature-rich.
- Often used by developers for complex coding tasks.
5. Summary of Key Concepts
✅ List popular Linux text editors, both command-line and GUI-based.
✅ Describe features of gedit, the default GUI editor in GNOME.
✅ Open and edit files using nano and vim from the command line.
✅ Understand basic commands for navigating and saving files in nano and vim.
Quick Reference Table
Editor | Type | Strengths | Common Use Case |
---|---|---|---|
nano | CLI | Simple, easy to use | Quick edits, beginner-friendly |
vim | CLI | Powerful, fast, modal | Advanced editing, scripting |
gedit | GUI | User-friendly, syntax highlighting | Desktop development, casual editing |
emacs | CLI/GUI | Highly extensible, customizable | Development, long-term projects |
Linux Distributions
1. What is a Linux Distribution (Distro)?
A Linux distribution, or distro, is a specific version or “flavor” of the Linux operating system.
Key Components of a Linux Distro:
- Must include the Linux kernel – the core component that communicates with hardware.
- Includes a set of default utilities and applications.
- Comes with a Graphical User Interface (GUI) for user interaction.
- Supports various shell commands for terminal-based operations.
- Offers different support models:
- Community-backed or enterprise-supported.
- May be a Long-Term Support (LTS) release or follow a rolling release model.
There are hundreds of Linux distros, each tailored for specific audiences or tasks like servers, desktops, embedded systems, or educational purposes.
2. What Differentiates Linux Distributions?
Linux distributions differ in several key ways:
Feature | Description |
---|---|
Default Applications & Utilities | Each distro comes with its own set of pre-installed software tools. |
Graphical User Interface (GUI) | Some use GNOME, KDE, XFCE, or other desktop environments. |
Shell Commands & Tools | May vary slightly depending on the distro’s configuration and package manager. |
Support Model | Community-driven (e.g., Debian) or enterprise-backed (e.g., Red Hat). |
Release Cycle |
|
3. Popular Linux Distributions
1. Debian
- First Release: 1993 (version 0.01), first stable release in 1996 (v1.1).
- Features:
- Stable, reliable, and fully open source.
- Supports many hardware architectures.
- Maintained by a community-run project.
- Use Case:
- Widely used in server environments due to its stability.
- Foundation for many other distros like Ubuntu.
2. Ubuntu
- First Official Release: 2004.
- Base: Based on Debian.
- Developer: Maintained by Canonical Ltd.
- Editions:
- Ubuntu Desktop: For personal computers and workstations.
- Ubuntu Server: For file servers and cloud infrastructure.
- Ubuntu Core: Designed for IoT devices.
- Use Case:
- Popular among beginners and developers.
- Used in cloud computing and enterprise environments.
3. Red Hat Enterprise Linux (RHEL)
- Developer: Maintained by Red Hat (an IBM subsidiary).
- Features:
- Commercial-grade OS focused on enterprise customers.
- Fully open source but requires subscription for official support.
- Use Case:
- Commonly used in large enterprises, data centers, and mission-critical applications.
4. Fedora
- Developer: Sponsored by Red Hat.
- Relation to RHEL: Code from Fedora is often incorporated into RHEL after testing.
- Features:
- Stable and secure with advanced firewall features.
- Actively developed with a growing community.
- Use Case:
- Favored by developers and contributors who want cutting-edge features before they appear in RHEL.
5. SUSE Linux Enterprise (SLE)
- Developer: Maintained by SUSE, a German open-source company.
- Editions:
- SLES (Server Edition): For enterprise servers.
- SLED (Desktop Edition): For enterprise desktop users.
- Features:
- Supports multiple architectures including ARM (e.g., Raspberry Pi).
- Uses SUSE Package Hub for extended software packages.
- Use Case:
- Common in enterprise environments, especially in Europe and Asia.
6. Arch Linux
- Features:
- Do-it-yourself approach – minimal base system that users customize.
- Highly configurable and lightweight.
- Follows a rolling release model – always up-to-date with latest software.
- Learning Curve:
- Requires strong knowledge of Linux internals.
- Use Case:
- Popular among advanced users and enthusiasts who prefer full control over their system.
4. Summary
✅ What a Linux distribution is and what components it includes.
✅ The differences between Linux distros based on GUI, tools, support, and release cycles.
✅ The unique features and use cases of popular distros such as Debian, Ubuntu, Red Hat, Fedora, SUSE, and Arch Linux.
Quick Comparison Table
Distro | Type | Use Case | Support | Release Model |
---|---|---|---|---|
Debian | Community | Servers | Free | Stable releases |
Ubuntu | Commercial | Desktop, Cloud | Canonical | LTS & Regular |
RHEL | Enterprise | Enterprise Servers | Paid | Stable releases |
Fedora | Community | Development | Red Hat | Rolling updates |
SUSE | Enterprise | Enterprise Systems | SUSE | Stable releases |
Arch | Community | Customization | Community | Rolling release |
Linux Terminal Overview
1. What is the Linux Shell?
Definition:
The Linux shell is an OS-level application that interprets and executes commands entered by a user.
Key Points:
- In early Unix/Linux systems, the shell was the only interface available.
- Today, GUIs exist, but the shell remains a powerful and flexible tool.
- It allows users to:
- Run programs
- Manipulate files (copy, move, delete)
- Read/write data
- Search and filter content
- Can also be used for scripting, automating repetitive tasks.
Popular Shells:
- Bash (Bourne Again SHell) – Most widely used.
- Zsh (Z Shell) – More modern features and customization.
2. What is the Linux Terminal?
Definition:
A terminal is an application or interface where you type commands and view their output.
How It Works:
- You enter commands in the terminal.
- The terminal sends them to the shell for execution.
- The shell communicates with the OS and hardware.
- Results are returned to the terminal for display.
Example:
python myprogram.py
This runs a Python script called myprogram.py
and displays its output (e.g., “Hello, World!”).
3. How Terminal and Shell Work Together
Step-by-Step Execution Flow:
- User types a command in the terminal.
- Terminal sends the command to the shell.
- Shell interprets the command and communicates with the operating system and kernel.
- Kernel interacts with hardware to execute the task.
- Once completed, results are passed back through the chain to the terminal, where they are displayed to the user.
4. Understanding the Command Line Interface (CLI)
Command Prompt:
- The blinking cursor where you type your commands.
- Often shows the current working directory.
- Example prompt:
/home/me/Documents $
Current Working Directory:
- This is the directory where the shell will look for files or run commands.
- You can change it using the
cd
command.
5. Navigating the Filesystem Using the Terminal
Basic Commands for Navigation:
Command | Description |
---|---|
cd / | Move to the root directory (/ ) |
cd bin | Move into the bin directory from current location |
cd ~ | Go to the user’s home directory |
cd .. | Move up one level to the parent directory |
cd ../.. | Move up two levels in the directory tree |
cd /home/me/Documents | Navigate directly to a specific path |
6. Understanding Paths in Linux
Path:
A human-readable location of a file or directory in the filesystem.
Types of Path Notation:
Symbol | Meaning | Example |
---|---|---|
/ | Root directory | /home/user/file.txt |
~ | User’s home directory | ~/Documents |
. | Current directory | ./file.txt |
.. | Parent directory | ../other_folder |
Path structure uses forward slashes:
Example:a/b
means “b” is inside “a”.
7. Listing Files and Running Programs
List Files in Current Directory:
ls
- Displays all files and directories in the current folder.
Run an Executable File:
./ls
- Runs the
ls
program located in the current directory.
Note: Many commands like
ls
are built into the shell and don’t require./
.
8. Practical Examples
Example 1: Navigating to the Home Directory
cd ~
Even if ls
isn’t in the current directory, you can still use it because it’s part of the system PATH.
Example 2: Moving Up and Down the Filesystem
cd ../..
Moves up two levels in the directory hierarchy.
cd /home/me/Documents
Navigates directly to the Documents folder.
Example 3: Running a Python Script
cd /home/me
python myprogram.py
Runs a Python script named myprogram.py
located in the current directory.
9. Summary
✅ What the Linux shell is and how it interprets commands.
✅ What a terminal is and how it serves as the interface for interacting with the shell.
✅ How the terminal and shell work together to execute commands via the kernel and hardware.
✅ How to navigate directories using the cd
command and understand path structures in Linux.
Quick Reference Table
Task | Command |
---|---|
Change to root directory | cd / |
Go to home directory | cd ~ |
Move to parent directory | cd .. |
Move to specific path | cd /home/me/Documents |
List contents of current directory | ls |
Run a Python script | python myprogram.py |
Browsing Directories with the Linux Terminal
Learning Objectives
By the end of this guide, you will be able to:
✅ Understand what a Linux terminal is and how it works
✅ Use the pwd
command to display your current working directory
✅ Use the ls
command to list contents of a directory
1. What Is the Linux Terminal?
The Linux terminal, also known as:
- Command line
- Shell prompt
- Command prompt
It is a text-based interface used to interact with the operating system by typing commands.
Understanding the Prompt
You may see something like:
/home/project $
/home/project
– This is the current working directory$
– The command prompt, where you type commands
On some systems, you might see
#
instead of$
. A#
indicates you’re logged in as a superuser (root).
2. pwd
– Print Working Directory
Purpose
Shows the full path of the directory you are currently in.
Usage
pwd
Example Output
/home/project
This means you are in the project
subdirectory inside the home
directory.
3. ls
– List Directory Contents
Purpose
Displays files and directories in the current location or specified location.
Basic Usage
ls
If the current directory is empty, the command returns no output — not even a blank line.
List Contents of a Specific Directory
You can specify a directory path:
ls /home
Example Output
project theia
This shows that the /home
directory contains two subdirectories: project
and theia
.
4. Understanding Filesystem Paths
Linux uses a tree-like structure for organizing files and directories.
Root Directory
- Represented by
/
(called “slash”) - The topmost directory in the filesystem
Subdirectories
- Folders within other folders
- Example:
/home/project
means:project
is a subdirectory insidehome
home
is a subdirectory inside the root (/
)
Path Examples
Path | Description |
---|---|
/ | Root directory |
/home | Home directory (contains user directories) |
/home/project | User-specific directory for projects |
5. Summary of Commands
Command | Description | Example |
---|---|---|
pwd | Print Working Directory – show current location | pwd → /home/project |
ls | List contents of current directory | ls |
ls <dir> | List contents of a specific directory | ls /home |
6. Final Notes
- The terminal allows you to interact with your Linux system using text commands.
- Use
pwd
to always know where you are in the file system. - Use
ls
to explore what’s inside a directory. - You can navigate through the Linux file system using paths and commands like
cd
, which you’ll learn more about in future lessons.
Linux Terminal Tips: Tab Completion & Command History
Learning Objectives
By the end of this guide, you will be able to:
✅ Use Tab Completion to speed up command typing
✅ Use Command History to reuse or edit previous commands
These two features help make working in the Linux terminal faster, more efficient, and less error-prone.
1. Tab Completion – Speed Up Typing Commands
What is Tab Completion?
A time-saving feature that auto-fills partially typed commands, file names, or paths when you press the Tab key.
Works for:
- Commands
- File names
- Directory paths
How It Works
- Type part of a name and press Tab
- The shell tries to complete it automatically
- If multiple matches exist, pressing Tab again may show suggestions or do nothing until more characters are entered
Examples
Example 1: Navigate to Pictures
cd P<TAB>
Becomes:
cd Pictures/
Because Pictures
is the only directory starting with “P”.
Example 2: Ambiguous Match (Do → Documents vs Downloads)
cd Do<TAB>
No auto-complete because both Documents
and Downloads
start with “Do”.
Example 3: Specific Match (Doc → Documents)
cd Doc<TAB>
Becomes:
cd Documents/
Only one match found.
Example 4: Long Path Completion
Inside ~/Documents
:
cd py<TAB>
If there’s only one folder named python-examples
, it becomes:
cd python-examples/
You can keep pressing Tab to go deeper into nested directories if they’re unambiguous.
2. Command History – Reuse Previous Commands
What is Command History?
Linux keeps a record of all commands you’ve entered during your session.
You can navigate this list using:
- ↑ (Up Arrow) – Go back through older commands
- ↓ (Down Arrow) – Move forward toward newer commands
This lets you reuse or modify previous commands without retyping them.
How to Use It
Scenario: You ran these commands
cd ~/Documents/python-examples
python3 myprogram.py
cd /
Now, at the prompt:
/ $
Step 1: Press ↑ once
Repeats the last command:
cd /
Step 2: Press ↑ again
Repeats:
python3 myprogram.py
Step 3: Press ↑ again
Repeats:
cd ~/Documents/python-examples
Tip: If you go too far back, use the ↓ arrow to move forward through history.
3. Summary Table
Feature | Description | Example |
---|---|---|
Tab Completion | Auto-completes commands, filenames, or paths | Type cd Doc<TAB> → completes to cd Documents/ |
Command History | Recalls previously used commands | Use ↑ and ↓ arrows to scroll through commands |
4. Final Tips
- Use Tab Completion to avoid typos and save time.
- Use Command History to repeat or tweak earlier actions.
- Combine both features to work faster and smarter in the terminal.
Exercise 1 - Browsing Directories with ls
In this exercise, you’re learning how to navigate and view the contents of directories using the ls
command in a Linux shell environment.
📌 Summary of Key Concepts
🔹 What is ls
?
ls
is a command used to list directory contents.- It is actually a program located at
/bin/ls
. - When you type
ls
, the shell runs/bin/ls
to show files and folders in the current or specified directory.
✅ 1.1 Viewing Files in the Current Working Directory
Command:
ls
Explanation:
- This lists all files and directories in your current working directory.
- In this lab environment, your current directory is
/home/project
. - Since it’s empty, running
ls
returns nothing (no output).
✅ 1.2 Viewing Files in Any Directory
You can list the contents of any directory by specifying its path:
Command:
ls [PATH TO DIRECTORY]
Example:
ls /
- Lists the contents of the root directory (
/
).
Common System Directories:
Directory | Contents |
---|---|
/bin | Essential user command binaries (like ls , cp , mv ) |
/sbin | System administration binaries |
/usr | User programs and data |
/home | Home directories for users |
/media | Mount points for removable media |
🧪 Try These Commands
To explore the system, try these in your terminal:
ls / # List root directory contents
ls /bin # List commands available in /bin
ls /home # See what users exist (you may see 'project')
ls /etc # Configuration files
ls /usr/bin # More user-level command binaries
💡 Tip
-
If you want to see hidden files (those starting with a dot), use:
ls -a
-
To get a detailed list (including file permissions, size, owner, etc.):
ls -l
Exercise 2 - Navigating Directories with cd
In this exercise, you’re learning how to change directories using the cd
(change directory) command in a Linux shell.
🧭 Key Navigation Symbols
Symbol | Meaning | Example |
---|---|---|
~ | Your home directory | cd ~ goes to /home/theia |
/ | The root directory of the system | cd / |
. | The current directory | cd . stays where you are |
.. | The parent directory | cd .. moves up one level |
✅ 2.1 Changing to Your Home Directory
cd ~
- This takes you to your default home directory, which is typically
/home/theia
in this lab environment. - To confirm:
pwd
✅ 2.2 Going to the Parent Directory
cd ..
- Moves up one level in the directory hierarchy.
- Example: If you’re in
/home/theia
, this will take you to/home
.
✅ 2.3 Changing to the Root Directory
cd /
- Takes you to the top-level directory of the file system, called the root directory.
✅ 2.4 Changing to a Child Directory
Method 1: Relative Path
cd bin
- From
/
, this will go to/bin
. - Assumes
bin
is a subdirectory of your current working directory.
Method 2: Using .
(Current Directory)
cd ./bin
- Also changes to
/bin
if you’re currently in/
.
⚠️ Tip: Make sure you’re in the correct parent directory before navigating into a child directory. If you’re already in
/bin
, typingcd ./bin
would try to go to/bin/bin
, which may not exist.
✅ 2.5 Returning to Your Home Directory
Option 1: Using ~
(Fastest Way)
cd ~
- Directly returns you to
/home/theia
.
Option 2: Using Relative Path
cd ../home/theia
- Goes up to
/home
, then into thetheia
folder.
✅ 2.6 Navigating to the Project Directory
cd ../project
- This switches you from
/home/theia
to its sibling directory:/home/project
. - Useful for moving between related folders inside
/home
.
📌 Final Tips
- Use
pwd
(Print Working Directory) often to see where you are:pwd
- Combine paths using slashes:
cd /home/project/myfolder
- Tab completion helps! Start typing a directory name and press Tab to auto-complete.
Exercise 3 - Using Tab Completion and Command History
In this exercise, you learned two powerful tools to make working in the terminal faster, easier, and less error-prone:
- 🔁 Command history
- ✨ Tab completion
🔄 3.1 Scrolling Through Command History
You can easily review and reuse previously entered commands using:
Key | Action |
---|---|
↑ (Up Arrow) | Go back one command |
↓ (Down Arrow) | Go forward one command |
Example:
If you previously typed:
cd /
cd bin
ls
Then pressing ↑
will bring back ls
, then cd bin
, then cd /
, etc.
Use Case:
Let’s say you want to run cd bin
again:
- Instead of retyping it, press
↑
until you seecd bin
- Press
Enter
to execute it again
💡 If the command doesn’t work because your current directory changed, keep scrolling until you find
cd /
, run that first, then trycd bin
.
🧠 3.2 Using Tab Completion
Tab completion helps you type faster by auto-filling file and directory names.
How It Works:
Step-by-step example:
- Type:
cd /bi
- Press
Tab
- It autocompletes to:
cd /bin
- It autocompletes to:
What if there are multiple matches?
Try typing:
cd /b
Then press Tab
once → nothing happens
Press Tab
twice → You’ll see options like:
bin/ boot/
Now add an i
:
cd /bi
Press Tab
again → completes to:
cd /bin
Tip:
- Double-tab (
Tab + Tab
) shows all possible completions. - Only works when there’s one match or you’re asking for help with ambiguous paths.
🛠️ Practice: Digging Into a Path Using Tab Completion
Let’s build a longer command using tab completion:
Start typing:
ls /ho
Press Tab → becomes:
ls /home/
Now type:
ls /home/the
Press Tab → becomes:
ls /home/theia
Keep going:
ls /home/theia/dsdriver/bi
Press Tab → becomes:
ls /home/theia/dsdriver/bin
This way, you built:
ls /home/theia/dsdriver/bin
…without typing the whole thing!
✅ Summary of Tips
Feature | Shortcut | Description |
---|---|---|
Command History | ↑ / ↓ | Scroll through previous commands |
Tab Completion | Tab | Auto-complete file/directory names |
Show Options | Tab + Tab | List possible completions |
Speed & Accuracy | Mix of both | Avoid typos and save time |
Linux Packages and Package Managers
1. What Are Packages in Linux?
A package is a file that contains:
- The software application or update
- Metadata (version, dependencies, etc.)
- Installation scripts
Packages are used to install, update, or remove software on Linux systems.
Common package formats:
.deb
– for Debian-based distributions.rpm
– for Red Hat-based distributions
2. Understanding Package Managers
What Is a Package Manager?
A tool that automates the process of:
- Downloading packages from repositories
- Installing, updating, configuring, and removing software
- Resolving dependencies automatically
Types of Package Managers:
Type | Description | Examples |
---|---|---|
GUI-based | Visual interface for managing software | Update Manager, PackageKit |
CLI-based | Terminal-based tools | apt , yum , dnf |
3. Differences Between .deb and .rpm Packages
Feature | .deb | .rpm |
---|---|---|
Used by | Debian, Ubuntu, Linux Mint | CentOS, RHEL, Fedora, openSUSE |
Package manager | apt , dpkg | yum , dnf , rpm |
File extension | .deb | .rpm |
Conversion possible? | Yes, using the alien tool |
Example: Convert an RPM to DEB format:
sudo alien package.rpm
Convert a DEB to RPM format:
sudo alien -r package.deb
4. GUI-Based Package Managers
Update Manager (Debian/Ubuntu)
- Default GUI tool for
.deb
systems. - Automatically checks for updates daily.
- Installs security updates automatically.
- Allows manual update checking and selection of specific updates.
PackageKit / Software Update (RPM-based Systems)
- Default GUI tool for
.rpm
systems like Fedora or CentOS. - Shows a notification icon when updates are available.
- Lets you select and install updates with password authentication.
5. Command-Line Package Managers
For Debian/Ubuntu (.deb): apt
APT stands for Advanced Package Tool.
Common Commands:
Task | Command |
---|---|
Update package list | sudo apt update |
Upgrade all packages | sudo apt upgrade |
Install a specific package | sudo apt install package_name |
Remove a package | sudo apt remove package_name |
Search for a package | apt search keyword |
For Red Hat/CentOS/Fedora (.rpm): yum
/ dnf
yum
: Older but widely used on CentOS/RHEL 7dnf
: Newer version used in Fedora and RHEL 8+
Common Commands (yum/dnf):
Task | Command |
---|---|
Update all packages | sudo yum update or sudo dnf upgrade |
Install a package | sudo yum install package_name or sudo dnf install package_name |
Remove a package | sudo yum remove package_name or sudo dnf remove package_name |
Search for a package | yum search keyword or dnf search keyword |
6. Using Package Managers to Install Software
You can use package managers not only for system-level applications but also for programming languages and development tools.
Example: Installing Python Libraries via pip
pip install pandas
This command:
- Searches for the latest version of
pandas
- Downloads and installs it
- Installs any required dependencies
Similar tools exist:
conda
– for data science environmentsnpm
– for JavaScript/Node.jsgem
– for Ruby
7. Summary
✅ Define what a Linux package is and how it’s used.
✅ Differentiate between .deb and .rpm package formats and understand how they can be converted.
✅ Use GUI-based package managers like Update Manager and PackageKit to check and install updates.
✅ Use CLI tools like apt
and yum
to manage software on your system.
✅ Install new software using package managers for both system and development purposes.
Quick Reference Table
Task | Debian/Ubuntu (.deb) | Red Hat/CentOS/Fedora (.rpm) |
---|---|---|
GUI Tool | Update Manager | PackageKit |
CLI Tool | apt | yum / dnf |
Update System | sudo apt update && sudo apt upgrade | sudo yum update |
Install Package | sudo apt install package_name | sudo yum install package_name |
Remove Package | sudo apt remove package_name | sudo yum remove package_name |
Search Package | apt search keyword | yum search keyword |
Exercise 1 - Upgrading and Installing Packages with apt
In this exercise, you learned how to use the sudo
command along with apt
, a powerful package management tool in Linux. You used it to:
- Update your system’s package list
- Upgrade an existing package (
nano
) - Install a new package (
vim
)
🔐 1.1 Updating Your System’s Package List Index
Command:
sudo apt update
What It Does:
- Fetches the latest list of available packages and their versions from configured repositories.
- Ensures that your system knows about the most recent software updates and dependencies.
🕒 This command may take a few moments to complete.
💡 You can view the repository sources at/etc/apt/sources.list
.
✏️ 1.2 Upgrading nano
Command:
sudo apt upgrade nano
What Happens:
- Upgrades the already installed
nano
text editor to the latest version. - You’ll be prompted:
Do you want to continue? [Y/n]
- Press
Y
then Enter to proceed.
⚠️ If you see a
:
prompt during the process (like in a pager), pressq
to quit and continue.
💾 1.3 Installing vim
Command:
sudo apt install vim
Why Vim?
- Vim is a highly configurable, powerful text editor.
- Ideal for editing files directly in the terminal.
- Widely used by developers and system administrators.
Installation Steps:
- Run:
sudo apt install vim
- Confirm with:
TypeDo you want to continue? [Y/n]
Y
and press Enter
🧠 Note: Always run
sudo apt update
before installing or upgrading packages to ensure you’re getting the latest software versions.
📌 Summary Table
Task | Command |
---|---|
Update package list | sudo apt update |
Upgrade a package (e.g., nano) | sudo apt upgrade nano |
Install a new package (e.g., vim) | sudo apt install vim |
🧪 Quick Tips
- To check if a package is installed:
which nano
- To view the version of a program:
nano --version vim --version
Exercise 2 - Creating and Editing Files with nano
In this exercise, you learned how to create and edit files using the nano
text editor from the command line.
🧭 2.1 Navigating to Your Project Directory
Command:
cd /home/project
Tip: Use Tab Completion
You can type:
cd /home/pr
Then press Tab, and it will auto-complete to:
cd /home/project
Once there, verify with:
ls
- This shows the contents of your directory.
- Since it’s empty at first, you won’t see anything yet.
✏️ 2.2 Creating and Editing a File with nano
Create a new file:
nano hello_world.txt
This opens the nano
editor and creates the file.
Inside Nano:
- Type:
Hello world!
- Press Enter
- Type:
This is the second line of my first-ever text file created with nano.
Save and Exit:
- Press CTRL + X to exit
- You’ll be prompted:
Save modified buffer? Y Yes N No ^C Cancel
- Press Y to save
- Confirm the filename by pressing Enter
Nano saves the file and returns you to the terminal.
🔍 2.3 Verifying Your File Content
To view the contents of your file:
cat hello_world.txt
You should see:
Hello world!
This is the second line of my first-ever text file created with nano.
✅ Success! You’ve just created and edited your first file in Linux using nano
.
📋 Summary of Commands
Action | Command |
---|---|
Navigate to project directory | cd /home/project |
Create/edit a file with nano | nano hello_world.txt |
Save and exit in nano | CTRL + X , then Y , then Enter |
View file contents | cat hello_world.txt |
🧠 Pro Tip:
If you ever get stuck inside nano
, remember:
- Use arrow keys to navigate
- Look at the bottom of the screen for shortcut hints like
^X
(CTRL+X)
Exercise 3 - Creating and Editing Files with Vim
In this exercise, you learned how to use Vim, a powerful and highly configurable text editor that is widely used in Linux environments. Vim uses different modes for editing and executing commands.
🧭 3.1 Quick Intro to Vim
Launching Vim
To start Vim:
vim
You’ll see something like:
VIM - Vi IMproved
...
:type :q<Enter> to exit
:type :help<Enter> for on-line help
Basic Commands
Mode | Action | Command |
---|---|---|
Normal (Command) Mode | Open help | :help |
Normal Mode | Quit Vim | :q |
Any Mode | Force quit without saving | :q! |
Normal Mode | Save file | :w |
Normal Mode | Save and quit | :wq |
Try It:
- Enter
:help
to explore the built-in documentation. - Press
Esc
to make sure you’re in Normal Mode. - Type
:q
to exit help or:q!
to exit Vim without saving changes.
💡 Tip: If you ever get stuck in Vim, press
Esc
, then type:q!
to safely exit without saving.
✏️ 32.2 Creating and Editing a Text File with Vim
Step-by-step Instructions:
1. Navigate to your project directory:
cd /home/project
Use tab completion if possible:
cd /home/pr<TAB>
2. Create and open a new file:
vim hello_world_2.txt
This opens a new blank file in Normal Mode.
3. Switch to Insert Mode:
Press:
i
Now you can type into the file.
4. Add content:
Type:
Hello World!
Press Enter to go to the next line, then type:
This is the second line.
5. Exit Insert Mode:
Press:
Esc
You’re now back in Normal Mode.
6. Save the file:
Type:
:w
This writes (saves) the contents of the buffer to the file.
7. Quit Vim:
Type:
:q
You’ll return to the command prompt.
🔍 Verify Your File Was Saved
Use the cat
command to view the contents:
cat hello_world_2.txt
You should see:
Hello World!
This is the second line.
✅ Congratulations! You’ve created and edited a file using Vim.
📋 Summary of Key Commands in Vim
Task | Command |
---|---|
Start Vim | vim filename.txt |
Enter Insert Mode | i |
Exit Insert Mode | Esc |
Save file | :w |
Save and quit | :wq |
Quit without saving | :q! |
Get help | :help |
Quit help | :q |
🧠 Pro Tips:
- Always press
Esc
before typing:
to ensure you’re in Normal Mode. - Vim has many modes: Normal, Insert, Visual, and more — we only covered the basics here.
- To learn more about Vim, visit https://www.vim.org, where you’ll find tutorials, plugins, and tips from the community.
🎉 Summary: Great Job Completing the Lab!
You’ve just taken a big step in mastering essential Linux skills. Here’s what you accomplished:
🔧 System Administration Skills
You learned how to manage software on your system using apt
and sudo
:
- ✅ Updated package list:
sudo apt update
- ✅ Upgraded an existing package (
nano
):sudo apt upgrade nano
- ✅ Installed a new package (
vim
):sudo apt install vim
These are foundational skills for maintaining and customizing any Linux environment.
📝 Text Editing with Nano and Vim
You created and edited files using two powerful command-line editors:
- ✏️ Nano – beginner-friendly, great for quick edits
- Created and saved
hello_world.txt
- Viewed content using
cat hello_world.txt
- Created and saved
- 💻 Vim – powerful and efficient once you learn the modes
- Created and saved
hello_world_2.txt
- Practiced switching between Insert Mode and Command Mode
- Created and saved
This gives you flexibility depending on your use case or preference!
🖥️ Bash Shell Proficiency
Throughout this lab, you became more comfortable with:
- 🧭 Navigating directories using
cd
,pwd
, and tab completion - 📁 Listing contents of directories using
ls
- ⏳ Reusing commands via the command history (
↑
/↓
) - 🚀 Saving time with tab auto-completion
- 💾 Viewing file contents with
cat
These skills will help you become fluent in the terminal — the heart of Linux system administration and development.
🌱 What’s Next?
Here are some great next steps to continue building your Linux expertise:
🔍 File Management:
- Learn how to copy, move, and delete files with
cp
,mv
, andrm
- Explore directory trees using
tree
(install it if needed!)
🛠️ Advanced Vim:
- Practice more Vim navigation and editing shortcuts
- Try out visual mode, search/replace, and macros
📊 File Comparison:
- Use
diff
to compare files - Try
less
,head
, andtail
to view large files
🧪 Scripting:
- Start writing your first Bash script using
nano
orvim
- Make it executable with
chmod +x myscript.sh
🙌 Final Words
You’re well on your way to becoming confident and proficient in Linux. The more you explore, experiment, and practice, the more natural these tools will feel.
Remember: The terminal is not scary — it’s powerful. And now, it’s yours to master.
📄 Module 1 Cheat Sheet – Introduction to Linux
This cheat sheet summarizes the essential commands and concepts covered in this module. Keep it handy for quick reference while working in the Linux terminal.
🔧 Linux Terminal Tips
Task | Command |
---|---|
Autocomplete path or command | Tab key |
Scroll through command history | ↑ / ↓ arrow keys |
❓ Getting Information
Task | Command |
---|---|
View manual for a command (e.g., ls ) | man ls |
🗂️ Browsing and Navigating Directories
🧭 Special Path Symbols
Symbol | Meaning |
---|---|
~ | Your home directory |
/ | Root directory |
. | Current directory |
.. | Parent directory |
📁 Directory Commands
Task | Command |
---|---|
List contents of current directory | ls |
List contents of another directory | ls path_to_directory |
Show current working directory | pwd |
Change to a subdirectory | cd child_directory_name |
Move up one directory level | cd ../ |
Go to your home directory | cd ~ or just cd |
Go to root directory | cd / |
Switch to a sibling directory | cd ../sibling_dir_name |
Return to previous working directory | cd - |
📦 Upgrading and Installing Packages
Use
sudo
to run administrative commands.
Task | Command |
---|---|
Update package list | sudo apt update |
Upgrade an existing package (e.g., nano) | sudo apt upgrade nano |
Install a new package (e.g., vim) | sudo apt install vim |
✏️ Creating and Editing Files
Task | Command |
---|---|
Create or edit a file with nano | nano file_name.txt |
Create or edit a file with vim | vim file_name.txt |
💻 Vim Modes Reminder
- Normal Mode: Press
Esc
– use for navigation and commands - Insert Mode: Press
i
– use for typing/editing text
Common Vim Commands (in Normal Mode):
Action | Command |
---|---|
Save (write) file | :w |
Quit | :q |
Save and quit | :wq |
Quit without saving | :q! |
Get help | :help |
🎉 Summary & Highlights – Module Complete!
Great job completing this module! You’ve built a solid foundation in Linux fundamentals, from its history to core components and practical tools. Here’s a concise recap of what you’ve learned:
🕰️ A Brief History of Linux
- GNU Project (1980s):
Developed at MIT as a free, open-source alternative to Unix — meaning “GNU’s Not Unix”. - Linux Kernel (1991):
Created by Linus Torvalds — a free, open-source Unix-like kernel that became the heart of modern Linux OS.
💻 Where Is Linux Used Today?
Linux powers:
- 📱 Mobile devices (e.g., Android)
- 🖥️ Desktop computers
- 🌐 Servers (including most web servers)
- 🚀 Supercomputers
- ☁️ Cloud infrastructure
Its flexibility and stability make it ideal for both personal and enterprise environments.
🧩 Linux Distributions (Distros)
Different flavors of Linux tailored to specific needs:
Distribution | Use Case |
---|---|
Ubuntu | Beginner-friendly, desktop and server |
Debian | Stable, community-driven |
Fedora | Cutting-edge features, developer-focused |
Red Hat Enterprise Linux (RHEL) | Enterprise use, commercial support |
SUSE (SLES/SLED/OpenSUSE) | Enterprise and development |
Linux Mint | Easy for Windows users to switch |
Arch | DIY-oriented, rolling release model |
Each distro varies in:
- User interface (UI)
- Package management
- Support structure
- Target audience
🏗️ The Five Layers of Linux Architecture
- User Interface (UI): Where users interact with applications.
- Applications: Programs used to perform tasks (e.g., browsers, editors).
- Operating System: Manages system resources and ensures smooth operation.
- Kernel: The core of Linux; handles communication between software and hardware.
- Hardware: Physical components like CPU, memory, disk drives.
Everything runs on top of the kernel, which is the bridge between your apps and your computer’s physical components.
📁 Filesystem Overview
- Linux uses a tree-like hierarchical filesystem.
- Starts from the root directory (
/
). - Common directories:
/bin
– essential commands/etc
– configuration files/home
– user directories/usr
– user programs/var
– variable data (logs, caches)
🖥️ Shell and Terminal Basics
- A shell is a command-line interpreter (e.g., Bash).
- You interact with the shell via a terminal emulator.
- Key navigation commands:
cd
– change directoryls
– list contentspwd
– show current pathman
– view manual pages
✍️ Text Editors in Linux
You can edit files using:
- 🖋️ Command-line editors:
nano
– beginner-friendlyvim
/vi
– powerful but has a learning curve
- 🖼️ GUI-based editors:
gedit
Kate
- VS Code (available on Linux)
📦 Package Management
Two major package formats:
.deb
– used by Debian, Ubuntu, and derivatives.rpm
– used by Red Hat, Fedora, SUSE, and others
Common package managers:
- APT (Advanced Packaging Tool) – used in Debian/Ubuntu
- YUM/DNF – used in RHEL/Fedora
Basic commands:
sudo apt update # Update package list
sudo apt upgrade # Upgrade packages
sudo apt install # Install new packages
🧠 Final Thoughts
You now understand:
- The origins and evolution of Linux
- How Linux powers today’s digital world
- The structure of a Linux system
- How to navigate the terminal
- How to manage packages and edit files
This sets the stage for deeper exploration into scripting, permissions, networking, containers, and more!
📘 Ready for the Next Module?
Let me know if you’d like to dive into:
- Shell scripting
- File permissions
- Process management
- Networking basics
Or any other topic you’re curious about!
Keep up the awesome work — Linux mastery is within your reach! 🐧🚀