Linux Basics: The Complete Guide

Master Linux command line, file system, permissions, shell scripting, and system administration

Introduction

Welcome to the most comprehensive Linux basics guide for 2026. Linux powers over 96% of the world's top 1 million servers, all of the top 500 supercomputers, and billions of Android devices worldwide. Whether you're a developer, system administrator, or just curious about open-source operating systems, this guide will take you from beginner to confident Linux user.

96%
Top 1M Servers
100%
Top 500 Supercomputers
3B+
Android Devices
600+
Linux Distributions

Created by Linus Torvalds in 1991, Linux has grown from a hobby project into the backbone of modern computing. From cloud infrastructure to embedded systems, Linux is everywhere. This guide will teach you the fundamentals you need to work effectively with Linux systems.

What You'll Learn

This comprehensive guide covers Linux history, distributions, file system hierarchy, essential commands, file permissions, package management, process management, networking, shell scripting, text editors, system administration, and career paths with certifications.

What is Linux?

Linux is a free, open-source, Unix-like operating system kernel first released by Linus Torvalds on September 17, 1991. Technically, "Linux" refers only to the kernel, but the term is commonly used to describe complete operating systems built around it, properly called GNU/Linux distributions.

History of Linux

1969
Unix Created
Ken Thompson and Dennis Ritchie create Unix at Bell Labs
1983
GNU Project
Richard Stallman starts GNU Project to create free Unix-like OS
1991
Linux Kernel
Linus Torvalds releases first Linux kernel (version 0.01)
1992
GPL License
Linux released under GNU GPL, enabling free distribution
1993
Debian & Slackware
First major Linux distributions released
2008
Android
Google releases Android, based on Linux kernel
2026
Linux Everywhere
Linux powers cloud, mobile, embedded, supercomputers

Why Use Linux?

Security

Linux has robust security model with user permissions, SELinux, and frequent security updates.

Benefit: Less malware, better security

Free & Open Source

No licensing fees, full source code access, and active community support.

Benefit: Cost-effective, transparent

Customization

Highly customizable with multiple desktop environments, kernels, and configurations.

Benefit: Tailored to your needs

Stability

Known for stability and reliability. Many Linux systems run for years without rebooting.

Benefit: High uptime, reliable

Community

Massive global community with extensive documentation, forums, and support.

Benefit: Help always available

Powerful CLI

Command line interface offers unmatched power and automation capabilities.

Benefit: Efficient, scriptable

Linux is not an operating system. It's a philosophy of sharing knowledge and collaborating to build something greater than any one person could achieve alone.

โ€” Linus Torvalds

Linux Distributions

A Linux distribution (or "distro") is a complete operating system built around the Linux kernel, including system software, applications, and package management. There are over 600 active Linux distributions, each with unique features and target audiences.

Popular Linux Distributions

Distribution Base Package Manager Best For Difficulty
Ubuntu Debian APT Beginners, servers Easy
Debian Original APT Servers, stability Medium
Fedora Original DNF Developers, cutting-edge Medium
CentOS Stream Fedora DNF Enterprise servers Medium
Arch Linux Original Pacman Advanced users Hard
Linux Mint Ubuntu APT Windows migrants Easy
openSUSE Original Zypper Enterprise, developers Medium
Manjaro Arch Pacman Arch beginners Easy-Medium
Kali Linux Debian APT Security testing Medium
Rocky Linux RHEL DNF Enterprise (RHEL alternative) Medium

Choosing the Right Distribution

Decision Guide
New to Linux?
โ†’ Ubuntu or Linux Mint (user-friendly, great documentation)
Want stability for servers?
โ†’ Debian, Rocky Linux, or Ubuntu Server
Want cutting-edge software?
โ†’ Fedora or Arch Linux
Security testing?
โ†’ Kali Linux or Parrot OS
Learning advanced Linux?
โ†’ Arch Linux (build from scratch)
Match distribution to your goals and experience level!
Try Before Installing

Most distributions offer Live USB mode, allowing you to try Linux without installing. Create a bootable USB and test different distributions before committing to one.

Linux File System

Linux uses a hierarchical file system with a single root directory (/). Unlike Windows, which uses drive letters (C:, D:), Linux organizes everything under the root directory in a tree structure.

Linux Directory Structure

Directory Purpose Contains
/ Root directory Top of the file system hierarchy
/home User home directories Personal files for each user
/etc System configuration Configuration files for system and applications
/var Variable data Logs, spools, caches (data that changes)
/usr User programs Most user-installed software
/bin Essential binaries Essential command binaries
/sbin System binaries System administration commands
/tmp Temporary files Temporary files (cleared on reboot)
/opt Optional software Third-party software packages
/dev Device files Hardware device files
/proc Process information Virtual file system for process info
/boot Boot files Kernel and boot loader files
/lib Libraries Essential shared libraries
/root Root user home Home directory for root user
/media Removable media Mount point for removable media
/mnt Mount point Temporary mount points

Important Paths

# Common paths in Linux # User's home directory ~ โ†’ /home/username $HOME โ†’ /home/username # Current directory . โ†’ current directory # Parent directory .. โ†’ parent directory # Root directory / โ†’ root of file system # Common locations /etc/passwd โ†’ user accounts /etc/hosts โ†’ hostname mappings /var/log/syslog โ†’ system logs /etc/fstab โ†’ file system mounts
Case Sensitivity

Linux file system is case-sensitive. File.txt, file.txt, and FILE.TXT are three different files. This is different from Windows, which is case-insensitive.

Basic Commands

Linux commands are entered in the terminal (also called shell or command line). Here are the essential commands every Linux user should know.

Navigation Commands

# Print Working Directory - show current location $ pwd /home/username/documents # List directory contents $ ls file1.txt file2.txt folder1/ # List with details (long format) $ ls -l -rw-r--r-- 1 user group 1234 Jan 15 10:30 file1.txt # List all files (including hidden) $ ls -la # Change directory $ cd /path/to/directory $ cd .. # go to parent directory $ cd ~ # go to home directory $ cd # same as cd ~

File Operations

# Create a directory $ mkdir new_folder $ mkdir -p parent/child/grandchild # create nested directories # Create a file $ touch new_file.txt # Copy files $ cp source.txt destination.txt $ cp -r folder1 folder2 # copy directory recursively # Move/rename files $ mv old_name.txt new_name.txt $ mv file.txt /path/to/destination/ # Remove files $ rm file.txt $ rm -r folder # remove directory recursively $ rm -rf folder # force remove (use with caution!) # View file contents $ cat file.txt # display entire file $ less file.txt # view file page by page $ head file.txt # show first 10 lines $ tail file.txt # show last 10 lines $ tail -f log.txt # follow file in real-time

Search Commands

# Find files by name $ find /path -name "*.txt" $ find . -type f -size +100M # files larger than 100MB # Search inside files $ grep "pattern" file.txt $ grep -r "pattern" /path # recursive search $ grep -i "pattern" file.txt # case-insensitive # Which command - find executable location $ which python /usr/bin/python # Locate - fast file search (uses database) $ locate filename

Essential Commands Reference

Command Purpose Example
man Show manual page man ls
history Show command history history
clear Clear terminal screen clear
echo Print text echo "Hello"
wc Word/line count wc -l file.txt
sort Sort lines sort file.txt
uniq Remove duplicates uniq file.txt
diff Compare files diff file1 file2
tar Archive files tar -czf archive.tar.gz folder/
df Disk space usage df -h
du Directory size du -sh folder/
free Memory usage free -h
Tab Completion

Use Tab key for auto-completion of commands, file names, and paths. This saves time and prevents typos. Press Tab twice to see all available completions.

File Permissions

Linux has a robust permission system that controls who can read, write, and execute files. Every file has an owner, a group, and permissions for three categories: owner, group, and others.

Understanding Permissions

# Permission string format: -rwxrwxrwx # Position: 123456789 # First character: file type - โ†’ regular file d โ†’ directory l โ†’ symbolic link # Next 9 characters: permissions (3 groups of 3) # Owner permissions (positions 2-4) # Group permissions (positions 5-7) # Others permissions (positions 8-10) # Each group has 3 permission types: r โ†’ read (4) w โ†’ write (2) x โ†’ execute (1) - โ†’ no permission

Permission Examples

Permission Meaning Octal
rwxrwxrwx Full permissions for everyone 777
rwxr-xr-x Owner: full, Group: read+execute, Others: read+execute 755
rw-r--r-- Owner: read+write, Group: read, Others: read 644
rw------- Owner: read+write only 600
rwx------ Owner: full permissions only 700

Changing Permissions

# Change permissions using chmod # Using octal notation $ chmod 755 script.sh # rwxr-xr-x $ chmod 644 file.txt # rw-r--r-- $ chmod 600 .ssh/id_rsa # rw------- # Using symbolic notation $ chmod u+x script.sh # add execute for user (owner) $ chmod g-w file.txt # remove write for group $ chmod o=r file.txt # set read-only for others $ chmod a+r file.txt # add read for all # Recursive permission change $ chmod -R 755 folder/ # Change ownership $ chown user:group file.txt $ chown -R user:group folder/

Special Permissions

Be Careful with chmod 777

Never use chmod 777 on system files or sensitive directories. It gives everyone full permissions, creating major security risks. Use the minimum permissions needed.

Package Management

Linux distributions use package managers to install, update, and remove software. Each distribution family has its own package manager and package format.

Package Managers by Distribution

Distribution Family Package Manager Package Format Examples
Debian/Ubuntu APT .deb Ubuntu, Debian, Linux Mint
RHEL/Fedora DNF/YUM .rpm Fedora, RHEL, CentOS, Rocky
Arch Pacman .pkg.tar.zst Arch, Manjaro
openSUSE Zypper .rpm openSUSE

APT Commands (Debian/Ubuntu)

# Update package lists $ sudo apt update # Upgrade all packages $ sudo apt upgrade # Full upgrade (handles dependencies) $ sudo apt full-upgrade # Install a package $ sudo apt install package_name # Remove a package $ sudo apt remove package_name # Remove package and configuration $ sudo apt purge package_name # Search for a package $ apt search keyword # Show package information $ apt show package_name # Clean up $ sudo apt autoremove $ sudo apt clean

DNF Commands (Fedora/RHEL)

# Update package lists and upgrade $ sudo dnf upgrade # Install a package $ sudo dnf install package_name # Remove a package $ sudo dnf remove package_name # Search for a package $ dnf search keyword # Show package information $ dnf info package_name # List installed packages $ dnf list installed

Pacman Commands (Arch)

# Sync and update $ sudo pacman -Syu # Install a package $ sudo pacman -S package_name # Remove a package $ sudo pacman -R package_name # Search for a package $ pacman -Ss keyword # Clean cache $ sudo pacman -Sc
Using sudo

Most package management commands require root privileges. Use sudo before commands to run them with administrative privileges. You'll be prompted for your password.

Process Management

Linux runs many processes simultaneously. Understanding how to view, manage, and control processes is essential for system administration.

Viewing Processes

# List running processes $ ps $ ps aux # all processes, all users $ ps -ef # full format # Interactive process viewer $ top # real-time process view $ htop # enhanced top (if installed) # Find specific process $ pgrep firefox $ pidof nginx # Process tree $ pstree

Controlling Processes

# Kill a process by PID $ kill 1234 $ kill -9 1234 # force kill # Kill by name $ killall firefox $ pkill firefox # Run process in background $ command & # List background jobs $ jobs # Bring job to foreground $ fg %1 # Send to background $ bg %1 # Run with nohup (survive logout) $ nohup command &

System Resource Monitoring

# Check system load $ uptime 10:30:45 up 5 days, 3:45, 2 users, load average: 0.15, 0.10, 0.05 # Memory usage $ free -h total used free shared buff/cache available Mem: 15Gi 4.2Gi 8.5Gi 256Mi 3.1Gi 11Gi # Disk usage $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 100G 45G 55G 45% / # Directory size $ du -sh /home/user 2.3G /home/user
Process Signals

kill sends signals to processes. Common signals: SIGTERM (15) - graceful termination, SIGKILL (9) - force kill, SIGHUP (1) - reload configuration.

Networking

Linux has powerful networking tools for configuration, troubleshooting, and monitoring. Understanding these tools is essential for system administration.

Network Configuration

# Show network interfaces $ ip addr $ ip link # Show IP addresses $ ip a $ hostname -I # Show routing table $ ip route $ route -n # Configure interface (temporary) $ sudo ip addr add 192.168.1.100/24 dev eth0 # Enable/disable interface $ sudo ip link set eth0 up $ sudo ip link set eth0 down

Network Troubleshooting

# Test connectivity $ ping google.com $ ping -c 4 8.8.8.8 # Trace route $ traceroute google.com $ mtr google.com # DNS lookup $ dig google.com $ nslookup google.com $ host google.com # Check open ports $ ss -tulpn $ netstat -tulpn # Network statistics $ netstat -s

Remote Access

# SSH connection $ ssh user@hostname $ ssh -p 2222 user@hostname # custom port # Secure copy $ scp file.txt user@host:/path/ $ scp -r folder user@host:/path/ # Generate SSH keys $ ssh-keygen -t ed25519 # Copy SSH key to remote server $ ssh-copy-id user@host # Download files $ wget https://example.com/file.zip $ curl -O https://example.com/file.zip
SSH Security

For production servers: use SSH keys instead of passwords, disable root login, change default port, and use fail2ban to prevent brute force attacks.

Shell Scripting

Shell scripting allows you to automate tasks in Linux. Bash (Bourne Again Shell) is the most common shell and scripting language on Linux systems.

Basic Script Structure

#!/bin/bash # This is a comment # Script to demonstrate basic bash scripting # Variables NAME="World" COUNT=5 # Print output echo "Hello, $NAME!" # Read user input echo "Enter your name:" read USER_NAME echo "Nice to meet you, $USER_NAME!" # Conditional statement if [ $COUNT -gt 3 ]; then echo "Count is greater than 3" else echo "Count is 3 or less" fi # Loop for i in 1 2 3 4 5; do echo "Number: $i" done

Script Example: Backup Script

#!/bin/bash # Backup script for home directory BACKUP_DIR="/backup" SOURCE_DIR="/home/user" DATE=$(date +%Y%m%d_%H%M%S) BACKUP_FILE="$BACKUP_DIR/backup_$DATE.tar.gz" # Create backup directory if it doesn't exist mkdir -p "$BACKUP_DIR" # Create backup echo "Creating backup: $BACKUP_FILE" tar -czf "$BACKUP_FILE" "$SOURCE_DIR" # Check if backup was successful if [ $? -eq 0 ]; then echo "Backup created successfully!" echo "Backup size: $(du -h "$BACKUP_FILE" | cut -f1)" else echo "Backup failed!" exit 1 fi

Running Scripts

# Make script executable $ chmod +x script.sh # Run script $ ./script.sh # Run with bash explicitly $ bash script.sh # Run with sh $ sh script.sh
Shebang Line

Always start scripts with #!/bin/bash (shebang line). This tells the system which interpreter to use. Without it, the script may not run correctly.

Text Editors

Linux offers several powerful text editors for editing files directly in the terminal. The most popular are Vim, Nano, and Emacs.

Nano (Beginner-Friendly)

# Open file with nano $ nano filename.txt # Common nano shortcuts (shown at bottom) ^O โ†’ Save file (Write Out) ^X โ†’ Exit ^K โ†’ Cut line ^U โ†’ Paste (Uncut) ^W โ†’ Search ^\ โ†’ Replace ^G โ†’ Help

Vim (Advanced)

# Open file with vim $ vim filename.txt # Vim has different modes: # - Normal mode (default) # - Insert mode (for typing) # - Command mode (for commands) # Basic vim commands (in normal mode) i โ†’ Enter insert mode Esc โ†’ Return to normal mode :w โ†’ Save (write) :q โ†’ Quit :wq โ†’ Save and quit :q! โ†’ Quit without saving # Navigation (normal mode) h/j/k/l โ†’ Left/Down/Up/Right w โ†’ Next word b โ†’ Previous word 0 โ†’ Start of line $ โ†’ End of line gg โ†’ Start of file G โ†’ End of file # Editing (normal mode) x โ†’ Delete character dd โ†’ Delete line yy โ†’ Copy line p โ†’ Paste u โ†’ Undo Ctrl+r โ†’ Redo

Editor Comparison

Editor Learning Curve Features Best For
Nano Easy Basic editing Beginners, quick edits
Vim Steep Advanced, modal editing Power users, efficiency
Emacs Steep Extensible, feature-rich Advanced users, customization
Vim Tutorial

If you want to learn Vim, run vimtutor in the terminal. It provides an interactive tutorial that teaches Vim basics in about 30 minutes.

System Administration

System administration involves managing and maintaining Linux systems. This includes user management, services, logs, and system configuration.

User Management

# Add a new user $ sudo useradd -m username $ sudo adduser username # interactive # Set user password $ sudo passwd username # Delete a user $ sudo userdel username $ sudo userdel -r username # remove home directory # Modify user $ sudo usermod -aG groupname username # add to group # List users $ cat /etc/passwd $ getent passwd # Switch user $ su - username # Run command as another user $ sudo -u username command

Service Management (systemd)

# Start a service $ sudo systemctl start service_name # Stop a service $ sudo systemctl stop service_name # Restart a service $ sudo systemctl restart service_name # Enable service to start on boot $ sudo systemctl enable service_name # Disable service $ sudo systemctl disable service_name # Check service status $ sudo systemctl status service_name # List all services $ systemctl list-units --type=service # Common services $ sudo systemctl status ssh # SSH server $ sudo systemctl status nginx # Web server $ sudo systemctl status apache2 # Apache web server

Log Management

# View system logs $ journalctl $ journalctl -xe # recent errors $ journalctl -u nginx # nginx logs $ journalctl -f # follow logs in real-time # Traditional log files $ tail -f /var/log/syslog $ tail -f /var/log/auth.log # authentication logs # Search logs $ grep "error" /var/log/syslog

System Information

# System information $ uname -a # kernel info $ lsb_release -a # distribution info $ hostnamectl # hostname and OS info # Hardware information $ lscpu # CPU info $ lsblk # block devices $ lspci # PCI devices $ lsusb # USB devices # System resources $ top # process monitor $ htop # enhanced process monitor $ free -h # memory usage $ df -h # disk usage
Root Access

Many system administration tasks require root privileges. Use sudo before commands to run them with administrative privileges. Be careful when using root accessโ€”mistakes can damage the system.

Career & Certifications

Linux skills are in high demand across IT, cloud computing, cybersecurity, and development. Professional certifications validate your expertise and can boost your career.

Linux Career Paths

Role Salary Range (US) Key Skills Focus
Linux System Administrator $70K-$110K System management, scripting Server management
DevOps Engineer $100K-$160K CI/CD, automation, cloud Automation & deployment
Cloud Engineer $110K-$170K AWS/Azure/GCP, Linux Cloud infrastructure
Site Reliability Engineer $120K-$180K Linux, monitoring, automation System reliability
Security Engineer $100K-$160K Linux security, hardening System security
Linux Developer $90K-$140K C/C++, kernel, scripting Linux development

Top Linux Certifications

CompTIA Linux+

Entry-level certification covering Linux fundamentals and administration.

Level: Beginner
Cost: ~$392

LPIC-1

Linux Professional Institute Certification Level 1. Vendor-neutral Linux certification.

Level: Beginner-Intermediate
Cost: ~$400 (2 exams)

RHCSA

Red Hat Certified System Administrator. Hands-on, performance-based certification.

Level: Intermediate
Cost: ~$400

RHCE

Red Hat Certified Engineer. Advanced automation and administration.

Level: Advanced
Cost: ~$400

LFCS

Linux Foundation Certified System Administrator. Vendor-neutral, hands-on.

Level: Intermediate
Cost: ~$395

LFCE

Linux Foundation Certified Engineer. Advanced Linux engineering.

Level: Advanced
Cost: ~$395

Learning Resources

Practice Makes Perfect

The best way to learn Linux is by using it daily. Install Linux on your computer, use it for daily tasks, and practice commands regularly. Hands-on experience is invaluable.

Conclusion

Linux is a powerful, flexible, and free operating system that powers much of the modern computing infrastructure. From servers to supercomputers, from smartphones to embedded devices, Linux is everywhere. Mastering Linux opens doors to exciting career opportunities in IT, cloud computing, cybersecurity, and development.

Key Takeaways

Your Linux Learning Journey

  1. Install Linux: Set up a Linux system (VM, dual boot, or dedicated)
  2. Learn basics: Master essential commands and file system
  3. Practice daily: Use Linux for daily tasks
  4. Learn scripting: Automate tasks with bash scripts
  5. Specialize: Focus on system admin, DevOps, security, or development
  6. Get certified: Validate your skills with certifications
  7. Contribute: Join the Linux community, contribute to projects

Linux is about imagination. It's not about the technology, it's about what you can do with it. The only limit is your creativity.

โ€” Linux Community Wisdom
Start Today

The best time to start learning Linux is now. Open a terminal, type your first command, and begin your journey. Every expert was once a beginner. The Linux community is welcoming and supportiveโ€”don't hesitate to ask questions and seek help.

Thank you for reading this comprehensive Linux basics guide. We hope it provides you with the knowledge and confidence to start or advance your Linux journey. The terminal is waiting for you. Happy hacking!