A Beginner’s Guide to Linux Installation and Basic Commands

Installing a Linux Operating System: A Step-by-Step Guide

1. Prepare Installation Media

  • Download ISO: Visit the official website of your chosen Linux distribution (e.g., Ubuntu, Fedora, Debian) and download the ISO image.
  • Create Bootable Media: Utilize a tool like Rufus (Windows) or Etcher (cross-platform) to create a bootable USB drive using the downloaded ISO.

2. Boot from Installation Media

  • Insert USB Drive: Connect the bootable USB drive to your computer.
  • Restart Computer: Restart your computer and access the BIOS/UEFI settings (typically by pressing F2, F12, ESC, or DEL during startup).
  • Change Boot Order: Prioritize the USB drive as the primary boot device.
  • Save and Exit: Save the changes and exit the BIOS/UEFI settings.

3. Start the Installation Process

  • Boot into Live Environment: Your computer will boot into the live environment of the Linux distribution.
  • Begin Installation: Locate and click the “Install [Distribution]” icon on the desktop or menu.

4. Set Up Installation Parameters

  • Select Language: Choose your preferred language for the installation.
  • Prepare Installation: Follow the on-screen prompts to configure the installation.
    • Keyboard Layout: Select your keyboard layout.
    • Updates and Third-Party Software: Decide whether to install updates and third-party software for graphics, Wi-Fi, and media formats.

5. Disk Partitioning

  • Installation Type: Choose your preferred installation type. Options may include:
    • Erase Disk and Install Linux: This option removes all data on the selected disk and installs Linux.
    • Something Else: This option allows for manual partitioning, suitable for advanced setups.
  • Create/Select Partitions: If manually partitioning, create or select partitions for root (`/`), swap, and optionally home (`/home`).

6. Configure User and System Settings

  • Time Zone: Select your time zone.
  • User Information: Provide your full name, username, password, and computer name.
  • Review Settings: Double-check all settings before initiating the installation.

7. Begin Installation

  • Start Installation: Click the “Install Now” button to commence the installation process.
  • Wait for Completion: The installer will copy files and install the system, which may take a while.
  • Remove Installation Media: Once the installation is complete, remove the USB drive when prompted.

8. Restart and Boot into Linux

  • Restart Computer: Click “Restart Now” to reboot your computer.
  • Boot into New System: Your computer should now boot into the newly installed Linux operating system.

9. Post-Installation Setup

  • Update System: Open a terminal and run the package manager commands to update your system (e.g., `sudo apt update && sudo apt upgrade` for Ubuntu).
  • Install Additional Software: Install any necessary additional software through the software manager or terminal.
  • Configure Settings: Customize system settings, user preferences, and configure any additional hardware as needed.

Understanding Linux Links

Hard Links

Concept: A hard link is essentially an additional name for the same data on disk. It shares the same inode number as the original file.

Behavior:

  • Changes made through either the original file or the hard link are reflected in both.
  • Deleting the original file doesn’t affect the hard link, as it still points to the valid data. However, deleting the last hard link removes the file entirely.
  • Hard links cannot span across different file systems; they must reside on the same file system.

Example:

ln file1 hard_link_to_file1 # Create a hard link

ls -l # Check inode numbers

Soft Links (Symbolic Links)

Concept: A soft link is a separate file that acts as a shortcut, storing the pathname (location) of the original file.

Behavior:

  • Changes made to the original file are reflected through the soft link.
  • Deleting the original file renders the soft link useless (dangling link), as it no longer points to a valid file.
  • Deleting the soft link itself has no effect on the original file.
  • Soft links can span across different file systems.

Example:

ln -s file2 another_link.txt # Create a soft link

ls -l

Essential Linux Commands

1. ls (List Files and Directories)

Examples:

  • ls: Lists files and directories in the current directory.
  • ls -l: Lists files with detailed information (long format).
  • ls -a: Lists all files, including hidden files.
  • ls <directory>: Lists contents of a specified directory.

2. cat (Concatenate and Display Files)

Examples:

  • cat myfile.txt: Displays the contents of “myfile.txt”.
  • cat file1.txt file2.txt: Displays the contents of “file1.txt” followed by “file2.txt”.

3. rm (Remove Files and Directories)

Options:

  • -r: Recursively deletes directories and their contents.
  • -f: Forces deletion without confirmation (use with caution!).
  • -i: Prompts for confirmation before deleting each file.

4. touch (Create or Update Files)

Examples:

  • touch newfile.txt: Creates a new empty file named “newfile.txt”.
  • touch existingfile.txt: Updates the modification time of “existingfile.txt”.

Introduction to Vim: The Command-Line Text Editor

Vim is a powerful text editor pre-installed on most Linux distributions. It’s known for its efficiency and extensive customization options.

Modes: Vim operates in different modes, including Insert mode for text editing and Normal mode for navigation and commands.

Navigation: Vim utilizes keyboard commands for cursor movement, copying, deleting, and more. This keyboard-centric approach enables rapid editing once you’re familiar with the shortcuts.

Efficiency: Vim’s keyboard-driven nature allows for faster editing compared to mouse-reliant editors.

Plugins: Vim offers extensive customization through plugins, tailoring it to your specific needs.

Basic Vim Commands

Navigation:

  • h, j, k, l: Move the cursor left, down, up, right, respectively.
  • w: Move to the start of the next word.
  • b: Move to the start of the previous word.
  • gg: Go to the beginning of the file.
  • G: Go to the end of the file.
  • n: Search forward for a pattern (repeat for the next instance).

Editing:

  • x: Delete the character under the cursor.
  • dw: Delete the word under the cursor.
  • dd: Delete the current line.
  • y: Yank (copy) text.
  • p: Paste yanked text.
  • r: Replace the character under the cursor (enter replace mode).

This guide provides a concise overview of Linux installation, basic commands, and the Vim text editor. For more in-depth information, consult the documentation and resources available for your specific Linux distribution.