Linux Terminal for Absolute Beginners

Tested on: Ubuntu 24.04 LTS · Debian 12 · Fedora 40 · Arch Linux · Linux Mint 22 — Last updated: June 2026

The Linux terminal is the single most powerful interface on any Linux system. It gives you direct, scriptable control over every layer of the OS — from file management and process control to network configuration and package installation. Every serious developer and sysadmin lives in the terminal. This guide gets you there from zero, with every command explained and tested.

Prerequisites

  • Any Linux distribution installed (physical machine, VM, or WSL2 on Windows)
  • A user account with sudo privileges
  • No prior terminal experience required

Opening the Terminal and Reading the Prompt

Every Linux desktop environment ships with a terminal emulator. The fastest ways to open one:

  • Keyboard shortcut: Ctrl + Alt + T — works on Ubuntu, Linux Mint, and most GNOME/XFCE desktops
  • Right-click the desktop: look for "Open Terminal Here" or "Open in Terminal"
  • Application menu: search for "Terminal", "Konsole" (KDE), "GNOME Terminal", "Alacritty", or "Kitty"
  • TTY (no desktop at all): press Ctrl + Alt + F2 through F6 to switch to a raw text console

Once open, you'll see a prompt. Read it carefully — it tells you who you are and where you are:

user@hostname:~$
  • user — your login username
  • hostname — the machine's name
  • ~ — your current directory; ~ is shorthand for /home/user
  • $ — you are a regular (non-root) user. A # here means you are root — every command runs with full system privileges

Never run commands as root unless a guide explicitly requires it and you understand what the command does.

Navigating the Filesystem

Linux organises everything under a single root directory /. There are no drive letters. Knowing where you are and how to move around is the foundation of everything else.

pwd — Print Working Directory

pwd
/home/user

Run this whenever you are disoriented. It shows your exact current location in the filesystem tree.

ls — List Directory Contents

# Basic listing
ls

# Long format: permissions, owner, size, date
ls -l

# Include hidden files (names starting with .)
ls -la

# Human-readable file sizes
ls -lah

# List a specific directory without going there
ls -la /etc/ssh

Sample output of ls -lah ~/Documents:

total 48K
drwxr-xr-x  3 user user 4.0K Jun 10 09:14 .
drwxr-xr-x 22 user user 4.0K Jun 10 08:55 ..
-rw-r--r--  1 user user  12K Jun 09 17:32 notes.txt
drwxr-xr-x  2 user user 4.0K Jun 08 14:01 project

The first column is the permission string. d means directory, - means file, l means symbolic link. The three groups of rwx after that represent permissions for owner, group, and everyone else.

cd — Change Directory

# Go to your home directory (both are equivalent)
cd
cd ~

# Absolute path (starts from root /)
cd /etc/ssh

# Relative path (from where you currently are)
cd Documents/project

# Go up one level
cd ..

# Go up two levels
cd ../..

# Jump back to the previous directory (toggle)
cd -

# Tab completion is your best friend — type cd Doc then press Tab

Memorise cd -. It switches between your two most recent directories instantly, which is faster than retyping paths.

Working with Files and Directories

Creating Files and Directories

# Create an empty file (also updates timestamps on existing files)
touch report.txt

# Create a directory
mkdir backups

# Create nested directories in one shot (-p = make parents as needed)
mkdir -p ~/projects/web/css

# Write text directly into a new file (> overwrites, >> appends)
echo "Hello, Linux!" > hello.txt
echo "Second line"  >> hello.txt

# Create a file with multiple lines using a heredoc
cat > config.txt << 'EOF'
host=localhost
port=8080
debug=true
EOF

Copying, Moving, and Deleting

# Copy a file
cp hello.txt hello-backup.txt

# Copy a directory and all its contents (-r = recursive)
cp -r ~/projects/web ~/projects/web-backup

# Move a file (also used to rename)
mv hello.txt greetings.txt

# Move a file into a directory
mv greetings.txt ~/Documents/

# Rename a directory
mv old-name new-name

# Delete a single file
rm report.txt

# Delete a directory and everything inside it
rm -rf backups/

Warning: rm -rf is permanent and irreversible. Linux has no recycle bin at the command line. Double-check your path before pressing Enter. A misplaced space in rm -rf / home/user (note the errant space) would attempt to delete the entire filesystem before failing. Always verify with ls first.

Reading File Contents

# Print entire file to screen
cat hello.txt

# View a large file one page at a time (j/k or arrows to scroll, q to quit)
less /etc/passwd

# Show only the first N lines (default 10)
head -20 /var/log/syslog

# Show only the last N lines
tail -20 /var/log/syslog

# Follow a log file in real time — new lines appear as they are written
tail -f /var/log/syslog

# Follow multiple files simultaneously
tail -f /var/log/syslog /var/log/auth.log

tail -f is invaluable when debugging services. Open it in one terminal pane while you trigger actions in another.

Getting Help Without Leaving the Terminal

# Full manual page for any command (q to quit, / to search within)
man ls
man find
man ssh

# Built-in help flag (shorter than man, usually shows all options)
ls --help
grep --help

# whatis — one-line description of a command
whatis grep

# apropos — search man pages by keyword
apropos "disk usage"

# tldr — practical, example-focused help pages (install separately)
sudo apt install tldr   # Debian/Ubuntu
tldr tar
tldr rsync

Installing and Managing Software

Package managers handle software installation, updates, and removal. The command syntax depends on your distribution family:

# ── Debian / Ubuntu / Linux Mint / Pop!_OS ──────────────────────────
sudo apt update              # Refresh the package index (always run before install)
sudo apt install vim htop    # Install one or more packages
sudo apt remove vim          # Remove a package (keep config files)
sudo apt purge vim           # Remove package AND config files
sudo apt upgrade             # Upgrade all installed packages
sudo apt autoremove          # Remove orphaned dependencies

# ── Fedora / RHEL / AlmaLinux / Rocky Linux ─────────────────────────
sudo dnf install vim htop
sudo dnf remove vim
sudo dnf update
sudo dnf autoremove

# ── Arch Linux / EndeavourOS / Manjaro ──────────────────────────────
sudo pacman -Syu             # Sync, refresh, and upgrade everything
sudo pacman -S vim           # Install
sudo pacman -Rs vim          # Remove package and unneeded dependencies
sudo pacman -Ss "text editor" # Search available packages

# ── openSUSE Tumbleweed / Leap ───────────────────────────────────────
sudo zypper refresh
sudo zypper install vim
sudo zypper remove vim
sudo zypper dup              # Full distribution upgrade (Tumbleweed)

Always run the update/refresh command before installing. Installing against a stale package index causes version conflicts and broken dependencies.

Running Commands as Administrator with sudo

# Prefix any command with sudo to run it as root
sudo apt update
sudo systemctl restart nginx

# Open a root shell (all subsequent commands run as root until you exit)
sudo -i

# Return to your normal user session
exit

# Run a command as root using the last command you typed
sudo !!

# Check what sudo privileges your account has
sudo -l

sudo prompts for your own password, not a separate root password. The authenticated session caches for roughly 15 minutes. Avoid running entire shell sessions as root — use sudo per-command so the blast radius of any mistake is limited.

Finding Files and Searching Content

# Find files by name (. means start searching from current directory)
find . -name "*.log"

# Find files in a specific directory, case-insensitive
find /var/log -iname "*.log"

# Find files modified within the last 7 days
find ~/projects -mtime -7

# Find files larger than 100MB
find / -size +100M -type f 2>/dev/null

# Search for text inside files — grep
grep "error" /var/log/syslog

# Case-insensitive
grep -i "error" /var/log/syslog

# Recursive search through all files in a directory tree
grep -r "TODO" ~/projects/

# Show line numbers in results
grep -n "def main" script.py

# Invert match — show lines that do NOT contain the pattern
grep -v "DEBUG" app.log

# Count matching lines
grep -c "404" /var/log/nginx/access.log

Pipes, Redirection, and Command Chaining

The pipe character | connects commands: the output of the left command becomes the input of the right. This lets you build precise, composable operations from simple tools.

# Find Firefox in the process list
ps aux | grep firefox

# Count how many files are in /etc
ls /etc | wc -l

# Sort lines in a file
cat names.txt | sort

# Remove duplicate lines (sort first — uniq only collapses adjacent duplicates)
sort names.txt | uniq

# Show the 5 largest files in current directory
du -sh * | sort -rh | head -5

# Page through long output
ls -la /etc | less

# Chain commands with && (second runs only if first succeeds)
sudo apt update && sudo apt upgrade -y

# Chain with || (second runs only if first fails)
mkdir newdir || echo "Directory already exists"

# Run commands sequentially regardless of success
sudo apt update ; sudo apt upgrade ; sudo apt autoremove

Output Redirection

# Write stdout to a file (creates or overwrites)
ls -la > filelist.txt

# Append stdout to a file
ls -la >> filelist.txt

# Redirect stderr (error output) to a file
find / -name "*.conf" 2> errors.txt

# Redirect both stdout and stderr to the same file
find / -name "*.conf" > results.txt 2>&1

# Discard all output entirely
command > /dev/null 2>&1

Managing Processes

# Snapshot of all running processes
ps aux

# Live, interactive process viewer (arrow keys to navigate, q to quit)
htop

# Find the PID of a running process by name
pgrep nginx

# Kill a process gracefully by PID (sends SIGTERM)
kill 3842

# Force-kill an unresponsive process (sends SIGKILL)
kill -9 3842

# Kill all processes matching a name
pkill firefox

# Run a command in the background (append &)
python3 server.py &

# List background jobs in current shell session
jobs

# Bring a background job to the foreground
fg %1

# Check system resource usage at a glance
top

Keyboard Shortcuts That Change Everything

These are not optional extras — they are core muscle memory for terminal efficiency.

ShortcutEffect
TabAutocomplete commands, paths, and arguments. Press twice to show all options.
↑ / ↓Scroll through previous commands
Ctrl + RReverse-search command history interactively — type a fragment, it finds the last matching command
Ctrl + CInterrupt and cancel the running command
Ctrl + ZSuspend the running command and return to the prompt (resume with fg)
Ctrl + LClear the terminal screen (equivalent to clear)
Ctrl + AJump to the beginning of the current line
Ctrl + EJump to the end of the current line
Ctrl + WDelete the word immediately before the cursor
Ctrl + UDelete everything from cursor to start of line
Ctrl + DExit the current shell session (same as typing exit)
!!Expand to the previous command — Go up