Linux Basics

Linux Basics

Introduction to Linux/Unix

Linux and Unix are powerful, multi-user, and multitasking operating systems widely used for servers, desktops, and embedded systems. While Unix originated in the 1970s as a proprietary system, Linux was developed in 1991 as an open-source alternative.


Key Characteristics:

  1. Open-Source: Linux is freely available, and its source code can be modified by anyone.

  2. Command-Line Oriented: Offers robust CLI tools for advanced users.

  3. Highly Customizable: Allows tailoring of the system to specific needs.

  4. Stable and Secure: Frequently used in enterprise environments due to its reliability.

  5. Unix-like: Linux shares many features and commands with Unix, making it a versatile system for developers and system administrators.


1. Kernel

The core part of the Linux operating system that interacts directly with the hardware. It manages system resources, such as CPU, memory, and devices.


2. Shell

An interface that allows users to interact with the operating system by typing commands. Popular shells include:

  • Bash (Bourne Again Shell→ recommended)

  • Zsh

  • Fish


3. Command Line Interface (CLI)

A text-based interface where users enter commands to perform tasks.


4. File System

The hierarchical structure used to store and organize files.

  • Root directory: / (base of the filesystem)

  • Home directory: /home/username


5. Processes

Programs running on your system. Each process has a unique identifier called a PID (Process ID).


6. Package Manager

Tools used to install, update, and remove software. Common ones include:

  • yum/dnf (Red Hat/CentOS/Fedora→ recommended)

  • apt (Debian/Ubuntu)

  • pacman (Arch Linux)


7. Permissions

Define who can read, write, or execute a file. Represented by:

  • Owner

  • Group

  • Others

Example: -rw-r--r--

  • r: Read

  • w: Write

  • x: Execute


8. Users and Groups

  • Users: Individuals with accounts on the system.

  • Groups: Collections of users with shared permissions.


9. Root User

The superuser with full administrative privileges. Be cautious while using root permissions.


10. Directory

A folder that can contain files or other directories. Common ones include:

  • /home: User home directories.

  • /etc: Configuration files.

  • /var: Log files and variable data.

  • /usr: User-installed software and libraries.


11. Shell Commands

Examples:

  • ls: List files in the current directory.
    Example: ls -l (shows detailed information about files and directories).

  • cd: Change to a specific directory.
    Example: cd /home (navigates to the /home directory).

  • pwd: Print the current working directory.
    Example: pwd (displays the full path of the current directory).

  • cp: Copy a file from one location to another.
    Example: cp file1.txt /home/user/ (copies file1.txt to the /home/user/ directory).

  • mv: Move or rename a file.
    Example: mv oldname.txt newname.txt (renames oldname.txt to newname.txt).

  • rm: Remove a file or directory.
    Example: rm file1.txt (deletes file1.txt).


12. Environment Variables

Settings that affect system or application behavior. Example: $PATH, which defines directories to search for executable files.


13. Text Editors

Used to create or edit text files. Popular ones include:

  • vim (recommended)

  • nano

  • emacs


14. Scripts

Files containing a series of commands to automate tasks, often written in Bash or other scripting languages.


15. Log Files

Files that record system and application activity, usually stored in /var/log.


16. Services and Daemons

  • Service: A background process running continuously (e.g., web server).

  • Daemon: A type of service that starts at boot.


17. Mounting

Connecting storage devices (like USB drives) to the system so you can access their contents.


18. Networking Commands

  • ping: Check connectivity to a server.
    Example: ping google.com (checks if google.com is reachable).

  • ifconfig/ip: Configure network interfaces.
    Example: ip addr show (displays IP addresses of network interfaces).

  • ssh: Connect to a remote machine.
    Example: ssh user@192.168.1.1 (connects to a remote machine with the specified IP).