Linux

Linux is an open-source operating system modeled on UNIX. Unlike proprietary operating systems like Windows or macOS, Linux is developed collaboratively, meaning its source code is freely available for anyone to view, modify, and distribute.

Technically, "Linux" refers only to the kernel—the core part of the operating system that manages the communication between your computer's hardware and software. The complete operating systems we use are called distributions (or "distros"), which combine the Linux kernel with user interfaces, package managers, and pre-installed software.


1. Understanding Linux Distributions (Distros)

Because Linux is open-source, different groups have packaged it in various ways to suit different needs. Here are a few common distributions:

  • Ubuntu: Highly popular, user-friendly, and excellent for beginners. It has strong community support and works well on desktops and servers.
  • Debian: Known for its extreme stability and strict adherence to free software principles. Ubuntu is actually built on Debian.
  • Fedora: Backed by Red Hat, Fedora focuses on integrating the latest features and software packages early.
  • Arch Linux: A lightweight, highly customizable distribution designed for experienced users who want to build their system from the ground up.
  • CentOS Stream / Rocky Linux: Enterprise-focused distributions commonly used in server environments.

2. The Linux Directory Structure

Unlike Windows, which uses drive letters (like C: and D:), the Linux file system is organized in a single unified tree structure. Everything starts at the root directory, represented by a single forward slash /.

Here are the most important directories you will encounter:

  • / (Root): The top-level directory. Every file and directory on your system resides here.
  • /home: Contains personal user directories (e.g., /home/username). This is where your documents, downloads, and personal settings are stored.
  • /etc: Contains system configuration files. Think of it as the settings folder for your operating system and programs.
  • /bin and /usr/bin: Contains essential command binaries (the programs you run from the command line, like ls or cd).
  • /var: Contains variable data, such as system logs (/var/log) and temporary database files.
  • /tmp: Holds temporary files created by the system or applications. These files are usually deleted when the system reboots.
  • /root: The home directory for the superuser (administrator), separate from normal users.

3. Navigating the Command Line Interface (CLI)

The terminal is one of the most powerful tools in Linux. Below are the basic commands needed to navigate and manage your system.

Basic Navigation

  • pwd (Print Working Directory): Shows you exactly which folder you are currently in.
    pwd
  • ls (List): Lists the files and folders inside your current directory.
  • ls -l shows detailed information (permissions, size, owner, date).
  • ls -a shows hidden files (files starting with a dot, like .bashrc).
    ls -la
  • cd (Change Directory): Moves you to a different folder.
  • cd /etc moves to the /etc directory.
  • cd .. moves up one level to the parent directory.
  • cd ~ or just cd takes you back to your home directory.
    cd /home/username/Downloads

4. Managing Files and Directories

These commands allow you to create, copy, move, and delete files and folders.

  • mkdir (Make Directory): Creates a new folder.
    mkdir my_new_folder
  • touch: Creates an empty file, or updates the timestamp of an existing file.
    touch notes.txt
  • cp (Copy): Copies files or folders.
  • To copy a file: cp source.txt destination.txt
  • To copy a folder (recursively): cp -r sourcefolder destinationfolder
    cp notes.txt backup_notes.txt
  • mv (Move/Rename): Moves a file or folder to a new location, or renames it.
    mv notes.txt Documents/
    mv old_name.txt new_name.txt
  • rm (Remove): Deletes files or directories. Note: Linux does not have a "Recycle Bin" for terminal deletions; once removed, files are generally difficult to recover.
  • Delete a file: rm notes.txt
  • Delete a folder and all its contents: rm -r folder_name
    rm -r old_project_folder

5. Viewing and Editing Files

To view or edit the contents of a file without a graphical user interface, you can use these tools:

Viewing Files

  • cat: Displays the entire contents of a file in the terminal.
    cat configuration.conf
  • less: Opens a file in a scrollable viewer (useful for long files). Press q to exit, and use arrow keys to navigate.
    less system.log
  • head / tail: Shows the first or last few lines of a file (default is 10 lines).
    tail -n 20 error.log  # Shows the last 20 lines of the file

Editing Files

  • nano: A simple, beginner-friendly text editor.
  • Open/create a file: nano document.txt
  • Save changes: Press Ctrl + O, then Enter.
  • Exit: Press Ctrl + X.
  • vim / vi: A powerful, advanced text editor. It has a steeper learning curve but is highly efficient once learned.

6. Permissions and Ownership

Linux is a multi-user operating system with security features designed to protect files from unauthorized access. Every file and directory has permissions associated with it.

If you run ls -l, you will see permission strings like this:
-rwxr-xr--

Understanding Permissions

The string is divided into four parts:
1. File Type: The first character (- for file, d for directory).
2. User (Owner): The next three characters (rwx). What the owner can do.
3. Group: The middle three characters (r-x). What members of the group can do.
4. Others: The final three characters (r--). What everyone else can do.

  • r = Read permission (view file contents)
  • w = Write permission (modify or delete the file)
  • x = Execute permission (run the file as a program or enter a folder)

Modifying Permissions and Ownership

  • chmod (Change Mode): Changes file permissions. You can use numbers (octal notation) to represent permissions:
  • 7 (Read, Write, Execute)
  • 6 (Read, Write)
  • 5 (Read, Execute)
  • 4 (Read Only)
    chmod 755 script.sh  # Owner can read/write/execute; others can read/execute.
  • chown (Change Owner): Changes the owner and group of a file.
    sudo chown username:groupname file.txt

Administrator Privileges (sudo)

Standard users cannot modify system files. To run a command with administrative (root) privileges, prepend the command with sudo (SuperUser DO).

sudo apt update

You will be prompted to enter your password to confirm.


7. Package Management (Installing Software)

Different Linux distributions use different package managers to install, update, and remove software.

Debian/Ubuntu (APT)

  • Update package list: sudo apt update
  • Install software: sudo apt install curl
  • Remove software: sudo apt remove curl

Fedora/RHEL (DNF)

  • Update package list & system: sudo dnf upgrade
  • Install software: sudo dnf install curl
  • Remove software: sudo dnf remove curl

Arch Linux (Pacman)

  • Update system: sudo pacman -Syu
  • Install software: sudo pacman -S curl
  • Remove software: sudo pacman -R curl

8. Basic System Monitoring

These commands help you keep track of your system’s performance and running applications.

  • top / htop: Shows running processes and resources (CPU, RAM). htop is a visually friendlier version of top (you may need to install it first). Press q to exit.
  • df -h: Displays available disk space in human-readable format (gigabytes/megabytes).
  • free -m: Shows memory usage (RAM) in megabytes.
  • ps aux: Lists all currently running processes.
  • kill <PID>: Stops a running process using its Process ID (PID).
    kill 1234

The guide was created in June 2026.