Vucense

Linux Command Line Basics 2026: 50 Essential Commands

🟢Beginner

Master the Linux command line with 50 essential commands. Covers navigation, file operations, pipes, redirection, text processing, process management, and shell scripting fundamentals on Ubuntu 24.04.

Linux Command Line Basics 2026: 50 Essential Commands
Article Roadmap

Key Takeaways

  • Pipes (|) are the power: Each command does one thing. Pipes connect them. command1 | command2 | command3 is the fundamental Linux idiom.
  • Tab completion is mandatory: Press Tab after typing the first few letters of any command, filename, or directory — the shell completes it. Double-Tab shows all matches.
  • man is always available: man ls, man grep, man find — offline, comprehensive documentation for every command. q to quit, / to search.
  • History saves time: Ctrl+R searches command history. !! repeats the last command. !ssh repeats the last command starting with ssh.

Introduction

Direct Answer: What are the most essential Linux command line commands every developer should know in 2026?

The 10 most critical Linux commands are: pwd (print working directory), ls -la (list files with details), cd (change directory), mkdir -p (create directory tree), cat/less/tail -f (read files), grep -r (search text), find (locate files), cp/mv/rm (copy/move/delete), sudo (run as root), and man (read documentation). Beyond these, the pipe operator (|) that connects commands and output redirection (>, >>) are the mechanisms that make Linux commands composable and powerful. On Ubuntu 24.04, these tools are pre-installed — no additional installation needed. The shell is bash 5.2 by default. Type echo $SHELL to confirm.


Part 1: Navigation

Linux navigation is the foundation of every shell workflow. These commands help you answer the two most important questions on any server or workstation: “Where am I?” and “What is here?” Knowing how to inspect directories, move between paths, and create folder structures is critical before editing configs, reviewing logs, or deploying applications.

# Where am I?
pwd
# /home/ubuntu

# What's in this directory?
ls                # Basic listing
ls -l             # Long format (permissions, owner, size, date)
ls -la            # Include hidden files (dotfiles)
ls -lh            # Human-readable sizes (KB, MB, GB)
ls -lt            # Sort by modification time (newest first)
ls -lS            # Sort by size (largest first)
ls /etc/nginx/    # List a specific directory

# Move around
cd /etc/nginx     # Go to absolute path
cd ..             # Up one level
cd ~              # Home directory
cd -              # Previous directory (toggle)
cd                # Home directory (no argument)

# Create directories
mkdir mydir                    # Create one directory
mkdir -p /opt/myapp/config     # Create full path (no error if exists)
mkdir -p project/{src,tests,docs}  # Create multiple at once (brace expansion)

# Show directory tree
find . -type d | head -20      # All subdirectories
# Or install tree: sudo apt-get install tree
tree -L 2 /etc/nginx           # Depth-limited tree view

Expected output of ls -lh /var/log/nginx/:

total 1.2M
-rw-r--r-- 1 www-data adm  847K Apr 28 09:00 access.log
-rw-r--r-- 1 www-data adm   12K Apr 28 09:00 error.log
-rw-r--r-- 1 www-data adm   58K Apr 27 00:00 access.log.1

Part 2: Reading Files

Inspecting file contents safely is essential for troubleshooting and configuration review. These commands let you read text files without editing them, page through long logs, preview headers and footers, and verify file metadata — all without altering the underlying data.

# Display file contents
cat file.txt                    # Entire file (stdout)
cat -n file.txt                 # With line numbers
less file.txt                   # Paginated (q=quit, /=search, n=next)
more file.txt                   # Simpler pager (space=next page)

# File beginnings and endings
head file.txt                   # First 10 lines
head -20 file.txt               # First 20 lines
tail file.txt                   # Last 10 lines
tail -20 file.txt               # Last 20 lines
tail -f /var/log/nginx/access.log  # Follow live (Ctrl+C to stop)

# Check file type and info
file /bin/bash                  # What kind of file is this?
wc file.txt                     # Lines, words, bytes
wc -l file.txt                  # Lines only
stat file.txt                   # Full metadata (size, permissions, timestamps)

Expected output of tail -f /var/log/nginx/access.log:

5.161.88.47 - - [28/Apr/2026:09:00:01 +0000] "GET / HTTP/1.1" 200 1234 "-" "curl/8.5.0"
5.161.88.47 - - [28/Apr/2026:09:00:05 +0000] "GET /health HTTP/1.1" 200 15 "-" "curl/8.5.0"

Part 3: File Operations

File management is where the Linux command line proves its efficiency. These commands cover copying, moving, renaming, and deleting files safely, plus creating empty files and managing permissions. Use them carefully; a single rm -rf can remove an entire directory tree.

# Copy
cp file.txt file-backup.txt          # Copy file
cp -r /etc/nginx /tmp/nginx-backup   # Copy directory recursively
cp -p file.txt dest/                 # Preserve permissions and timestamps

# Move / Rename
mv file.txt newname.txt              # Rename
mv file.txt /tmp/                    # Move to directory
mv /tmp/old/ /opt/new/               # Move directory

# Delete (⚠ no recycle bin — permanent)
rm file.txt                          # Delete file
rm -f file.txt                       # Force (no error if missing)
rm -r directory/                     # Delete directory recursively
rm -rf /tmp/old-build/               # Force recursive (be careful!)

# Create empty file / update timestamp
touch newfile.txt
touch -m existingfile.txt            # Update modification time only

# View and edit
nano file.txt                        # Beginner-friendly editor (Ctrl+O save, Ctrl+X exit)
vim file.txt                         # Powerful modal editor (i=insert, :wq=save+quit, :q!=quit no save)

# Links
ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/mysite  # Symlink
ln file.txt hardlink.txt             # Hard link

# Permissions
chmod 644 file.txt                   # rw-r--r-- (owner read/write, others read)
chmod 755 script.sh                  # rwxr-xr-x (owner execute, others read+execute)
chmod +x script.sh                   # Add execute bit for all
chown ubuntu:ubuntu file.txt         # Change owner and group
chown -R www-data:www-data /var/www/ # Recursive ownership change

Part 4: Searching

Finding files and text quickly is a core task for troubleshooting. This section shows how to locate configuration files, search logs for error messages, and act on results immediately. Combining find with grep is a powerful pattern for identifying faulty code, misconfigurations, or stale files across a server.

# Find files by name
find /etc -name "nginx.conf"         # Exact filename
find /var/log -name "*.log"          # Wildcard
find /home -name ".env" -type f      # Files only
find /tmp -mtime -1                  # Modified in last 24 hours
find / -size +100M -type f 2>/dev/null  # Files larger than 100MB

# Find and act
find /var/log -name "*.log" -exec ls -lh {} \;   # List each found file
find /tmp -mtime +7 -delete          # Delete files older than 7 days

# Search inside files
grep "error" /var/log/nginx/error.log       # Lines containing "error"
grep -i "error" file.txt                    # Case-insensitive
grep -n "error" file.txt                    # With line numbers
grep -r "password" /etc/                    # Recursive (all files in /etc)
grep -v "info" /var/log/syslog | head -20   # Lines NOT matching
grep -c "error" file.txt                    # Count matching lines
grep -l "error" src/*.py                     # List files containing match

# Advanced search
grep -E "error|warning" /var/log/syslog     # Extended regex (OR)
grep -P "(?:error|warn)\s+\d+" file.log     # Perl regex

Expected output of grep -rn "listen 80" /etc/nginx/sites-enabled/:

/etc/nginx/sites-enabled/example.com:2:    listen 80;
/etc/nginx/sites-enabled/app.example.com:3:    listen 80;

Part 5: Text Processing

The Linux shell is built for text. This section shows how to sort results, count unique values, extract fields, and transform text streams. These commands are the foundation of automation, log parsing, and quick data analysis on a terminal.

# Sort
sort file.txt                        # Alphabetical
sort -n numbers.txt                  # Numeric sort
sort -rn numbers.txt                 # Reverse numeric
sort -k2 -t: /etc/passwd             # Sort by field 2, delimiter ':'
sort -u file.txt                     # Sort + remove duplicates

# Unique (requires sorted input)
sort file.txt | uniq                 # Remove consecutive duplicates
sort file.txt | uniq -c             # Count occurrences
sort file.txt | uniq -d             # Show only duplicates

# Cut and process fields
cut -d: -f1 /etc/passwd             # First field (username)
cut -d, -f2,4 data.csv              # Fields 2 and 4 from CSV

# sed — stream editor
sed 's/old/new/g' file.txt          # Replace all "old" with "new"
sed -i 's/old/new/g' file.txt       # In-place replacement
sed -n '5,10p' file.txt             # Print lines 5-10
sed '/^#/d' config.txt              # Delete comment lines

# awk — field-based processing
awk '{print $1}' file.txt           # First word of each line
awk -F: '{print $1, $3}' /etc/passwd  # Username and UID
awk 'NR==5' file.txt                # Print line 5
awk '{sum += $1} END {print sum}' numbers.txt  # Sum first column
df -h | awk 'NR>1 {print $5, $6}'  # Disk usage % and mount point

Expected pipeline example:

# Find top 5 most common error types in Nginx log
grep "error" /var/log/nginx/error.log | \
  awk '{print $NF}' | \
  sort | uniq -c | sort -rn | head -5

Expected output:

     42 "no such file or directory"
     18 "connection refused"
      7 "upstream timed out"
      3 "permission denied"
      1 "SSL_do_handshake"

Part 6: Redirection and Pipes

Redirection and pipes are what make the Linux shell more than a calculator. By routing output between commands and into files, you can build reusable workflows, capture errors, and automate repeated tasks without writing a full program.

# Output redirection
command > file.txt          # Overwrite file with stdout
command >> file.txt         # Append stdout to file
command 2> error.txt        # Redirect stderr
command > output.txt 2>&1   # Redirect both stdout and stderr to same file
command > /dev/null         # Discard output
command 2>/dev/null         # Discard errors only

# Input redirection
command < file.txt          # Feed file as stdin
command << 'EOF'            # Here-document (type inline)
line 1
line 2
EOF

# Pipes
cmd1 | cmd2                 # Stdout of cmd1 → stdin of cmd2
cmd1 | cmd2 | cmd3          # Chain multiple commands

# Practical pipe examples
ps aux | grep nginx | grep -v grep            # Find nginx processes
cat /etc/passwd | cut -d: -f1 | sort          # Sorted username list
ls -la | awk '{print $5, $9}' | sort -rn      # Files sorted by size
du -sh /var/log/* | sort -h | tail -10        # 10 largest log directories

Part 7: Process Management

Understanding processes is essential for system health and application troubleshooting. These commands help you inspect running programs, terminate unresponsive tasks, and manage jobs started from the shell. Mastery of process control is critical on both development and production systems.

# List processes
ps aux                              # All processes
ps aux | grep nginx                 # Filter by name
top                                 # Interactive process monitor (q to quit)
htop                                # Better top (install: apt-get install htop)
pgrep nginx                         # Get PID(s) by name

# Control processes
kill PID                            # Send SIGTERM (graceful)
kill -9 PID                         # Send SIGKILL (force)
killall nginx                       # Kill all processes named nginx
pkill -f "python app.py"            # Kill by command pattern

# Background / foreground
command &                           # Run in background
jobs                                # List background jobs
fg %1                               # Bring job 1 to foreground
bg %1                               # Continue job 1 in background
nohup command &                     # Run after logout (immune to HUP signal)
Ctrl+C                              # Kill foreground process
Ctrl+Z                              # Suspend foreground process

Part 8: System Information

Before diagnosing a slow system, you need metrics. These commands provide a quick view of disk space, memory, CPU, uptime, and journal logs. Use them to verify capacity, find resource bottlenecks, and confirm that services are logging correctly.

# Disk usage
df -h                               # Disk space (human-readable)
df -h /                             # Specific filesystem
du -sh /var/log/                    # Size of directory
du -sh /var/log/* | sort -h         # Sizes of all items, sorted

# Memory
free -h                             # RAM and swap usage
cat /proc/meminfo | head -10        # Detailed memory info

# CPU and system
uname -a                            # Kernel version and architecture
lscpu                               # CPU details
uptime                              # Load average and uptime
cat /proc/loadavg                   # 1, 5, 15 minute load averages
nproc                               # Number of CPU cores

# System logs
journalctl -f                       # Follow system journal
journalctl -u nginx                 # Logs for nginx service
journalctl --since "1 hour ago"     # Recent logs
journalctl -p err                   # Error-level only

Expected output of free -h:

               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       1.8Gi       812Mi        12Mi       1.2Gi       1.9Gi
Swap:             0B          0B          0B

Part 9: Networking

Networking commands are essential when a server appears unreachable or a website is not responding. This section covers connectivity checks, port diagnostics, interface inspection, and DNS validation for both local and remote troubleshooting.

# Check connectivity
ping -c4 8.8.8.8                    # 4 ICMP packets to Google DNS
curl -sI https://example.com        # HTTP headers only
wget -q https://example.com -O -    # Download to stdout (quiet)

# Open ports
ss -tlnp                            # TCP listening ports with process
ss -tlnp | grep :80                 # Check if port 80 is in use
nc -zv host 443                     # Test if TCP port is open

# Network interfaces
ip addr show                        # All interfaces and IPs
ip route show                       # Routing table
ip route get 8.8.8.8                # Which route for specific IP

# DNS
resolvectl query example.com        # DNS lookup
dig example.com A                   # DNS query (install: apt-get install dnsutils)
host example.com                    # Simple DNS lookup

Part 10: Productivity Shortcuts

The last section focuses on speed. These history and shell shortcuts save time, reduce typing, and let you recover from mistakes faster. Power users rely on them to move through the terminal efficiently and keep workflows smooth.

# History
history                             # Show command history
history | grep docker               # Search history
Ctrl+R                              # Reverse search through history (type to search)
!!                                  # Repeat last command
!ssh                                # Repeat last command starting with "ssh"
!$                                  # Last argument of previous command

# Navigation shortcuts (in terminal)
Ctrl+A                              # Move to start of line
Ctrl+E                              # Move to end of line
Ctrl+U                              # Delete from cursor to start
Ctrl+K                              # Delete from cursor to end
Alt+Backspace                       # Delete previous word
Ctrl+L                              # Clear screen (same as 'clear')
Ctrl+C                              # Kill current process

# Command combinations
sudo !!                             # Re-run last command with sudo
cd !$                               # cd to the argument of last command
command && echo done                # Run second command only if first succeeds
command || echo failed              # Run second command only if first fails
command1 ; command2                 # Run both regardless of exit codes

Conclusion

These 50 commands cover 95% of daily Linux command-line work: navigating the filesystem, reading and searching files, processing text with pipes, managing processes, and checking system state. The composability of Linux tools — small programs doing one thing, connected by pipes — is what makes the command line powerful.

The natural next step is automation — see Bash Scripting Guide 2026 to turn these commands into scripts, and Linux systemd Service Management to manage services using systemctl and journalctl.


People Also Ask

These are the most common clarifying questions developers ask when working with Linux command-line workflows.

What is the difference between > and >> in Linux?

> redirects output and overwrites the target file — if it exists, its contents are replaced. >> redirects output and appends to the target file — existing content is preserved and new output is added at the end. Example: echo "first" > file.txt creates (or overwrites) file.txt with “first”. echo "second" >> file.txt adds “second” on a new line. Use > for fresh output; use >> for log files or accumulating results.

What does 2>&1 mean at the end of a command?

2>&1 redirects file descriptor 2 (stderr, error output) to wherever file descriptor 1 (stdout, normal output) is currently going. If you write command > output.txt 2>&1, stdout goes to output.txt and stderr is redirected to stdout (which is also output.txt) — both streams end up in the same file. Without 2>&1, error messages would still appear in the terminal while normal output goes to the file. The &1 means “file descriptor 1”, distinguishing it from a file named “1”.

How do I run multiple commands on one line in Linux?

Three operators: ; runs commands sequentially regardless of success (cmd1; cmd2); && runs the second command only if the first succeeds (cmd1 && cmd2); || runs the second command only if the first fails (cmd1 || cmd2). Common patterns: sudo apt-get update && sudo apt-get upgrade -y (only upgrade if update succeeded); command || echo "command failed" (print error message on failure); cd /tmp && rm -rf build/ && echo "cleaned" (chain cleanup steps safely).


Further Reading

External Resources

Tested on: Ubuntu 24.04 LTS. Bash 5.2.21. Last verified: April 28, 2026.

Divya Prakash

About the Author

AI Systems Architect & Founder

Graduate in Computer Science | 12+ Years in Software Architecture | Full-Stack Development Lead | AI Infrastructure Specialist

Divya Prakash is the founder and principal architect at Vucense, leading the vision for sovereign, local-first AI infrastructure. With 12+ years designing complex distributed systems, full-stack development, and AI/ML architecture, Divya specializes in building agentic AI systems that maintain user control and privacy. Her expertise spans language model deployment, multi-agent orchestration, inference optimization, and designing AI systems that operate without cloud dependencies. Divya has architected systems serving millions of requests and leads technical strategy around building sustainable, sovereign AI infrastructure. At Vucense, Divya writes in-depth technical analysis of AI trends, agentic systems, and infrastructure patterns that enable developers to build smarter, more independent AI applications.

View Profile

Further Reading

All Dev Corner

Comments