Reference library

Find a command by what you need to do.

These examples come from the same catalog used by the course. Search here for syntax, then open the linked mission to learn the command in context.

98 guided examples

Navigation & files

Where am I?

Day 1
Safe

Prints your current folder.

Terminal
pwd

Navigation & files

Identify your Linux environment

Day 1
Read-only

Shows the kernel, architecture, distribution details, and (when applicable) the WSL distribution name. These checks are safe on Ubuntu, most Linux distributions, and WSL.

Terminal
uname -srmo
cat /etc/os-release
if [ -n "$WSL_DISTRO_NAME" ]; then echo "WSL distro: $WSL_DISTRO_NAME"; fi

Navigation & files

List files

Day 1
Safe

Shows files in normal, detailed, hidden, human-readable, and time-sorted views.

Terminal
ls
ls -l
ls -la
ls -lh
ls -ltr

Navigation & files

Create first practice items

Day 1
Safe

Creates harmless files and a folder inside the sandbox.

Terminal
touch file1.txt file2.txt file3.txt
mkdir testdir
ls -la

Navigation & files

Move to home and back

Day 2
Safe

Moves home, then returns to the sandbox.

Terminal
cd ~
pwd
cd ~/linux-practice
pwd

Navigation & files

Practice parent folders

Day 2
Safe

Shows how .. climbs up one level at a time.

Terminal
cd ~/linux-practice
mkdir -p files/demo
cd files/demo
pwd
cd ..
pwd
cd ../..
pwd

Navigation & files

Return to previous directory

Day 2
Read-only

cd - switches back to the last directory you were in, without retyping the path.

Terminal
cd ~/linux-practice
cd /tmp
pwd
cd -
pwd

Navigation & files

Read-only visit to /etc

Day 2
Read-only

Visits Ubuntu configuration folders without editing anything.

Terminal
cd /etc
pwd
ls -l | head -20
cd ~/linux-practice

Navigation & files

Create files

Day 3
Safe

Creates empty files and demonstrates brace expansion.

Terminal
cd ~/linux-practice
touch myfile.txt
touch file_{1..5}.txt
ls -l

Navigation & files

Create and remove empty directories safely

Day 3
Safe

mkdir -p creates missing parent folders without failing when they already exist. rmdir removes only an empty directory, making it a safer first removal command than rm -r.

Terminal
cd ~/linux-practice
mkdir -p files/{inbox,archive}
ls -ld files files/inbox files/archive
rmdir files/archive

Navigation & files

Inspect file metadata

Day 3
Safe

Shows size, permissions, owner, timestamps, and inode.

Terminal
stat myfile.txt

Navigation & files

Identify file type

Day 3
Read-only

Compares a text file with a real executable.

Terminal
echo 'Hello Ubuntu' > myfile.txt
file myfile.txt
file /bin/bash

Navigation & files

Write and append

Day 4
Safe

Creates a file and appends another line. Remember: > overwrites.

Terminal
cd ~/linux-practice
echo 'First line' > journal.txt
echo 'Second line' >> journal.txt
cat journal.txt

Navigation & files

Number and reverse lines

Day 4
Safe

Shows numbered lines and reverse order.

Terminal
cat -n journal.txt
tac journal.txt

Navigation & files

Save output with tee

Day 4
Safe

Saves a directory listing while also displaying it.

Terminal
ls -la | tee listing.txt
cat listing.txt

Navigation & files

Create a large file

Day 5
Safe

Generates a harmless file for viewing practice.

Terminal
cd ~/linux-practice
for i in {1..100}; do echo "This is line number $i"; done > large.txt

Navigation & files

Preview file parts

Day 5
Safe

Shows first lines, last lines, and counts.

Terminal
head -n 5 large.txt
tail -n 5 large.txt
wc large.txt
wc -l large.txt

Navigation & files

Open with less

Day 5
Safe

Press Space for next page, /pattern to search, and q to quit.

Terminal
less -N large.txt

Text & pipelines

Overwrite and append

Day 6
Safe

Demonstrates the difference between replace and append.

Terminal
cd ~/linux-practice
echo 'First' > output.txt
echo 'Second' >> output.txt
cat output.txt

Text & pipelines

Capture errors

Day 6
Safe

Sends stderr to a file instead of the screen.

Terminal
ls missing-file 2> error.log
cat error.log

Text & pipelines

Use a heredoc

Day 6
Safe

Creates multi-line text safely.

Terminal
cat << 'EOF' > document.txt
Line 1
Line 2
Variables like $HOME are not expanded here
EOF
cat document.txt

Text & pipelines

Sort and count

Day 7
Safe

Sorts lines and counts adjacent duplicates after sorting.

Terminal
cd ~/linux-practice
echo -e 'banana\napple\ncherry\napple' > fruits.txt
sort fruits.txt | uniq -c

Text & pipelines

Translate characters

Day 7
Safe

Transforms text through a pipeline.

Terminal
echo 'Hello World' | tr 'a-z' 'A-Z'
echo 'Hello World' | tr ' ' '_'

Text & pipelines

Cut and align fields

Day 7
Safe

Extracts fields and prints a simple table.

Terminal
echo 'Name:Age:City' > people.txt
echo 'Jane:25:London' >> people.txt
cut -d: -f1,3 people.txt
column -t -s: people.txt

Text & pipelines

Basic grep

Day 8
Safe

Finds matching and non-matching lines.

Terminal
cd ~/linux-practice
echo -e 'Apple\napple\nAPPLE\nBanana\napricot' > fruits.txt
grep -i 'apple' fruits.txt
grep -v 'apple' fruits.txt

Text & pipelines

Regex anchors

Day 8
Safe

Uses start, end, and OR matching.

Terminal
grep '^A' fruits.txt
grep 'e
#x27; fruits.txt grep -E 'apple|Banana' fruits.txt

Text & pipelines

Recursive search

Day 8
Safe

Searches through folders.

Terminal
mkdir -p projects/search-demo
echo 'secret pattern' > projects/search-demo/file.txt
grep -r 'pattern' projects

Text & pipelines

Substitute safely

Day 9
Safe

Prints changed output without modifying the file.

Terminal
cd ~/linux-practice
echo -e 'Hello\nWorld\nHello World' > text.txt
sed 's/Hello/Hi/' text.txt
sed 's/Hello/Hi/g' text.txt

Text & pipelines

Print selected lines

Day 9
Safe

Shows only selected lines.

Terminal
sed -n '2p' text.txt
sed -n '1,2p' text.txt

Text & pipelines

In-place with backup

Day 9
Caution

Changes the file and keeps a backup copy.

Terminal
sed -i.bak 's/Hello/Hi/g' text.txt
cat text.txt
cat text.txt.bak

Text & pipelines

Print fields

Day 10
Safe

Prints columns and line numbers.

Terminal
cd ~/linux-practice
echo -e 'Name Age City\nJohn 30 NYC\nJane 25 LA' > data.txt
awk '{print $1, $3}' data.txt
awk '{print NR, $0}' data.txt

Text & pipelines

CSV separator

Day 10
Safe

Uses comma as a field separator and calculates values.

Terminal
echo -e 'Product,Price,Quantity\nApple,1.50,100\nBanana,0.75,200' > inventory.csv
awk -F, 'NR>1 {print $1, $2 * $3}' inventory.csv

Text & pipelines

Total calculation

Day 10
Safe

Accumulates a total and prints it at the end.

Terminal
awk -F, 'NR>1 {total += $2 * $3} END {print total}' inventory.csv

Safety & control

Create search lab

Day 11
Safe

Creates harmless test files.

Terminal
cd ~/linux-practice
mkdir -p find-lab/subdir/nested
touch find-lab/file1.txt find-lab/file2.pdf find-lab/old.log find-lab/subdir/test.txt

Safety & control

Find files

Day 11
Safe

Searches by name and type.

Terminal
find find-lab -name '*.txt'
find find-lab -type f
find find-lab -type d
find find-lab -empty

Safety & control

Act on results

Day 11
Safe

Lists matching files and prints logs before any deletion.

Terminal
find find-lab -name '*.txt' -exec ls -lh {} \;
find find-lab -name '*.log' -print

Safety & control

Delete only after printing

Day 11
Caution

Deletes only the practice .log file after you have confirmed the match.

Terminal
find find-lab -name '*.log' -delete

Safety & control

Practice chmod

Day 12
Safe

Changes permissions on your own practice file.

Terminal
cd ~/linux-practice
touch permissions_demo.txt
chmod 644 permissions_demo.txt
ls -l permissions_demo.txt
chmod 600 permissions_demo.txt
ls -l permissions_demo.txt

Safety & control

Make a script executable

Day 12
Safe

Adds execute permission to a practice script.

Terminal
echo 'echo Hello' > scripts/hello.sh
chmod +x scripts/hello.sh
./scripts/hello.sh

Safety & control

System special bits example

Day 12
Explanation

These examples explain SUID and sticky bit. Do not run them; Ubuntu already manages system permissions.

Terminal
chmod u+s /usr/bin/passwd
chmod +t /tmp

Safety & control

Who am I?

Day 13
Read-only

Shows your username, IDs, and groups.

Terminal
cd ~/linux-practice
whoami
id
groups

Safety & control

Inspect ownership

Day 13
Read-only

Shows ownership on your file and reads user/group databases.

Terminal
touch owned-by-me.txt
ls -l owned-by-me.txt
head -5 /etc/passwd
head -5 /etc/group

Safety & control

Optional admin ownership examples

Day 13
Admin

These change real system state. They are explained, not required for this safe course.

Terminal
sudo chown username:groupname file.txt
sudo adduser testlearner
sudo userdel -r testlearner

Safety & control

View processes

Day 14
Read-only

Shows current and system processes.

Terminal
ps
ps aux | head -15
pgrep -l bash

Safety & control

Create and stop a practice job

Day 14
Caution

Starts one harmless background process, captures its exact PID with $!, then stops and waits for that same process. This remains deterministic even when other jobs already exist.

Terminal
cd ~/linux-practice
sleep 100 &
practice_pid=$!
echo "Started practice PID: $practice_pid"
jobs -l
kill "$practice_pid"
wait "$practice_pid" 2>/dev/null || true
jobs -l

Safety & control

Broad process killing examples

Day 14
Caution

Useful but broad. Prefer job number or exact PID while learning.

Terminal
killall sleep
pkill -f 'sleep 200'

Safety & control

Inspect variables

Day 15
Read-only

Reads common environment variables.

Terminal
printenv | head -20
echo $HOME
echo $USER
echo $SHELL
echo $PATH

Safety & control

Export a temporary variable

Day 15
Safe

Creates and removes a temporary variable.

Terminal
export MY_NAME='Linux Learner'
echo $MY_NAME
bash -c 'echo Child sees: $MY_NAME'
unset MY_NAME

Safety & control

Practice PATH safely

Day 15
Safe

Temporarily adds your practice bin folder to PATH.

Terminal
mkdir -p ~/linux-practice/bin
export PATH="$HOME/linux-practice/bin:$PATH"
which ls
whereis bash
type cd

Safety & control

Find the command your shell will run

Day 15
Read-only

command -v is the portable way to find a command or shell builtin. command -V gives a fuller explanation, while env lists exported variables for the current process.

Terminal
command -v ls
command -v cd
command -V cd
env | sort | head -20

Applied workflows

Create and inspect aliases

Day 16
Safe

Creates a friendly listing shortcut.

Terminal
alias ll='ls -la'
ll
alias ll

Applied workflows

Remove aliases

Day 16
Safe

Removes the temporary shortcut.

Terminal
unalias ll
alias

Applied workflows

Bypass an alias

Day 16
Safe

Runs the original command even if an alias exists.

Terminal
alias ls='ls --color=auto'
command ls
\ls

Applied workflows

View history

Day 17
Read-only

Shows recent commands.

Terminal
history 10

Applied workflows

Repeat simple commands

Day 17
Caution

Repeats the previous harmless echo command.

Terminal
echo 'safe repeat demo'
!!

Applied workflows

History clearing example

Day 17
Caution

Clears current shell memory history. Explanation only for most learners.

Terminal
history -c

Applied workflows

Brace expansion

Day 18
Safe

Creates multiple practice files quickly.

Terminal
echo file_{1..5}.txt
touch file_{1..5}.txt
ls file_*.txt

Applied workflows

Globbing lab

Day 18
Safe

Shows common filename patterns.

Terminal
mkdir -p glob-lab
cd glob-lab
touch a.txt b.txt c.txt 1.txt 22.txt abc.txt
echo *.txt
echo ?.txt
echo [ab].txt
cd ..

Applied workflows

Safe cleanup

Day 18
Caution

Removes only the glob-lab folder created in the sandbox.

Terminal
rm -rf glob-lab

Applied workflows

Hard link demo

Day 19
Safe

Shows two names for the same file data.

Terminal
cd ~/linux-practice
echo 'Original content' > original.txt
ln original.txt hardlink.txt
ls -li original.txt hardlink.txt
echo 'Added line' >> original.txt
cat hardlink.txt

Applied workflows

Symlink demo

Day 19
Safe

Creates and inspects a symbolic link.

Terminal
echo 'Target content' > target.txt
ln -s target.txt symlink.txt
ls -l symlink.txt
readlink symlink.txt
cat symlink.txt

Applied workflows

Broken symlink

Day 19
Caution

Demonstrates a broken symlink inside the practice folder.

Terminal
rm target.txt
cat symlink.txt

Applied workflows

Create archive lab

Day 20
Safe

Creates a folder to archive.

Terminal
cd ~/linux-practice
mkdir -p archive-lab/docs
echo 'file1' > archive-lab/file1.txt
echo 'readme' > archive-lab/docs/README.txt

Applied workflows

Tar and inspect

Day 20
Safe

Creates a compressed tar archive and lists its contents.

Terminal
mkdir -p backups
tar -czvf backups/archive-lab.tgz archive-lab
tar -tvf backups/archive-lab.tgz

Applied workflows

Extract safely

Day 20
Safe

Extracts into a dedicated restored folder.

Terminal
mkdir -p restored
tar -xzvf backups/archive-lab.tgz -C restored
ls -R restored

System & network

Measure sandbox

Day 21
Safe

Shows size of the practice folder and its contents.

Terminal
cd ~/linux-practice
du -sh
du -sh * 2>/dev/null

System & network

Filesystem free space

Day 21
Read-only

Shows root filesystem free space and type.

Terminal
df -h /
df -hT /

System & network

Observe block devices

Day 21
Read-only

Reads storage and mount information only.

Terminal
lsblk
findmnt | head -20
mount | head -20

System & network

Read-only package search

Day 22
Read-only

Searches and inspects packages without installing anything.

Terminal
apt search 'text editor' | head -20
apt show nano | head -20
apt list --installed | head -20

System & network

Detect your package manager

Day 22
Read-only

Checks which common package-manager command is available without changing the system. Follow the APT examples only on Ubuntu, Debian, or their WSL distributions.

Terminal
command -v apt || true
command -v dnf || true
command -v pacman || true
command -v zypper || true

System & network

Inspect installed files

Day 22
Read-only

Uses dpkg to inspect installed package information.

Terminal
dpkg -l | head -20
dpkg -l | grep -i bash
dpkg -L bash | head -20

System & network

Optional install/remove pattern

Day 22
Admin

This changes the real Ubuntu system. It is optional and not part of the removable sandbox guarantee.

Terminal
sudo apt update
sudo apt install sl -y
sudo apt remove sl

System & network

Connectivity checks

Day 23
Read-only

Sends ICMP probes to a public address and the local loopback interface. A reply is useful evidence; no reply is inconclusive because networks and hosts may block ICMP.

Terminal
ping -c 2 8.8.8.8
ping -c 1 localhost

System & network

Check DNS separately from connectivity

Day 23
Read-only

Separates name lookup from ICMP reachability. If the IP address replies but name lookup fails, DNS is the likely layer to investigate. A failed ping alone does not prove the network is offline.

Terminal
getent hosts example.com
ping -c 1 example.com
ping -c 1 1.1.1.1

System & network

Fetch a web page

Day 23
Safe

Downloads into the sandbox downloads folder. -L follows redirects; -I fetches headers only.

Terminal
mkdir -p ~/linux-practice/downloads
cd ~/linux-practice/downloads
curl -IL https://example.com
curl -L -o example.html https://example.com
head -5 example.html

System & network

Inspect network info

Day 23
Read-only

Views addresses, routes, and listening ports.

Terminal
ip addr show | head -30
ip route show
ss -tuln | head -20
hostname -I

System & network

Memory and uptime

Day 24
Read-only

Shows memory, uptime, and short virtual memory stats.

Terminal
free -h
uptime
vmstat 1 2

System & network

Process snapshots

Day 24
Read-only

Shows a non-interactive top snapshot and memory-heavy processes.

Terminal
top -b -n 1 | head -20
ps aux --sort=-%mem | head -10

System & network

Logs and watch

Day 24
Read-only

Reads recent logs only when systemd is running, then starts a repeating clock. This handles non-systemd distributions and WSL environments where systemd is disabled. Stop watch with Ctrl+C.

Terminal
if command -v journalctl >/dev/null && [ "$(ps -p 1 -o comm=)" = systemd ]; then
  journalctl -n 20 --no-pager
else
  echo "systemd journal is not available in this environment"
fi
watch -n 2 date

Automation

Hello script

Day 25
Safe

Creates and runs a first script.

Terminal
cd ~/linux-practice/scripts
cat << 'EOF' > hello.sh
#!/usr/bin/env bash
echo "Hello, $USER!"
echo "Today is $(date)"
echo "You are in $PWD"
EOF
chmod +x hello.sh
./hello.sh

Automation

Arguments script

Day 25
Safe

Shows common script argument variables.

Terminal
cat << 'EOF' > args.sh
#!/usr/bin/env bash
echo "Script name: $0"
echo "First argument: $1"
echo "All arguments: $@"
echo "Number of arguments: $#"
EOF
chmod +x args.sh
./args.sh one two three

Automation

Exit status

Day 25
Read-only

Shows non-zero failure and zero success statuses.

Terminal
ls /nonexistent
echo "Exit status: $?"
ls /bin/bash
echo "Exit status: $?"

Automation

If/else demo

Day 26
Safe

Creates a basic conditional script.

Terminal
cd ~/linux-practice/scripts
cat << 'EOF' > if_demo.sh
#!/usr/bin/env bash
num=${1:-10}
if [ "$num" -gt 10 ]; then
  echo "Greater than 10"
elif [ "$num" -eq 10 ]; then
  echo "Exactly 10"
else
  echo "Less than 10"
fi
EOF
chmod +x if_demo.sh
./if_demo.sh 25

Automation

For loop

Day 26
Safe

Loops over fixed words. Saved in scripts/ alongside if_demo.sh.

Terminal
cd ~/linux-practice/scripts
cat << 'EOF' > for_demo.sh
#!/usr/bin/env bash
for fruit in apple banana cherry; do
  echo "I like $fruit"
done
EOF
chmod +x for_demo.sh
./for_demo.sh

Automation

Case statement

Day 26
Safe

Matches one value against multiple patterns. Saved in scripts/ alongside the other demo scripts.

Terminal
cd ~/linux-practice/scripts
cat << 'EOF' > case_demo.sh
#!/usr/bin/env bash
answer=${1:-yes}
case "$answer" in
  yes|y|YES|Y) echo "You agreed." ;;
  no|n|NO|N) echo "You disagreed." ;;
  *) echo "Invalid input" ;;
esac
EOF
chmod +x case_demo.sh
./case_demo.sh yes

Automation

Read current crontab

Day 27
Read-only

Checks that the crontab command exists before listing entries, and distinguishes a missing tool from an empty or inaccessible user crontab. Scheduling also requires a working cron-compatible service.

Terminal
if ! command -v crontab >/dev/null; then
  echo "crontab is not installed in this environment"
else
  crontab -l 2>/dev/null || echo "No user crontab exists, or access is unavailable"
fi

Automation

Safe scheduling simulation

Day 27
Safe

Simulates repeated scheduled work without editing crontab.

Terminal
cd ~/linux-practice
mkdir -p logs
for i in {1..3}; do echo "Simulated run at $(date)" >> logs/schedule-demo.log; sleep 2; done
cat logs/schedule-demo.log

Automation

Dangerous cleanup example

Day 27
Explanation

Removes the entire user crontab. Explanation only; do not use as course cleanup.

Terminal
crontab -r

Automation

Find command info

Day 28
Read-only

Discovers command locations, shell builtins, and descriptions. Prefer command -v over which in scripts because command is provided by the shell.

Terminal
command -v ls
command -V cd
whereis bash
type cd
whatis ls
apropos 'list directory' | head -10

Automation

Manual pages

Day 28
Read-only

Opens the ls manual. Press q to quit.

Terminal
man ls

Automation

Optional locate setup

Day 28
Admin

Installs plocate (the modern locate on Ubuntu 22.04+) and updates its database. Optional only.

Terminal
sudo apt install plocate -y
sudo updatedb
locate bashrc | head

Applied workflows

Inspect, do not edit

Day 29
Read-only

Reads the beginning of your real .bashrc without changing it.

Terminal
cat ~/.bashrc | head -30

Applied workflows

Temporary prompt

Day 29
Safe

Changes and restores the prompt only in the current shell.

Terminal
OLD_PS1=$PS1
PS1='Practice> '
echo 'Prompt changed for this session'
PS1=$OLD_PS1

Applied workflows

Practice alias file

Day 29
Safe

Sources aliases from a removable practice file.

Terminal
echo "alias showdate='date +%Y-%m-%d'" >> ~/linux-practice/my_aliases
source ~/linux-practice/my_aliases
showdate
unalias showdate

Applied workflows

Real .bashrc edit example

Day 29
Explanation

This permanently modifies your real shell startup file. Explanation only in this course.

Terminal
echo "alias la='ls -A'" >> ~/.bashrc

Applied workflows

Create final project

Day 30
Safe

Creates a complete mini project.

Terminal
cd ~/linux-practice
mkdir -p final_project/{src,docs,bin} backups
cd final_project
echo 'main function' > src/main.c
echo '# README' > docs/README.md
cat << 'EOF' > bin/script.sh
#!/usr/bin/env bash
echo 'Processing...'
for f in src/*; do
  echo "Found: $f"
  wc -l "$f"
done
EOF
chmod +x bin/script.sh

Applied workflows

Review skills

Day 30
Safe

Uses archive, find, grep, head, xargs, du, and script execution.

Terminal
cd ~/linux-practice/final_project
tar -czvf ../backups/final-project-v1.tgz src docs bin
tar -tzf ../backups/final-project-v1.tgz
find . -name '*.sh' -exec ls -lh {} \;
grep -r 'function' .
head -2 docs/README.md
find . -type f \( -name '*.c' -o -name '*.sh' \) -print0 | xargs -0 wc -l
du -sh .
./bin/script.sh

Applied workflows

Remove final project only

Day 30
Caution

Deletes only final_project inside the sandbox.

Terminal
cd ~/linux-practice
rm -rf final_project

Shortcuts:Alt + ← previous lessonAlt + → next lessonAlt + H home? focus search