Linux practice for beginners
Linux command practice.
Try it, then check your answer.
Work through 10 exercises using a small set of files and logs. Try each task before opening the answer, then compare your output.
Exercises and answers are free to read. Shell Samurai's hosted lab requires an account and email confirmation; Chapter 1 is free, with no card needed.
Where can I practice Linux commands?
Use a Linux terminal on your own machine, WSL on Windows, or a Linux virtual machine. If you want a hosted practice environment, Shell Samurai provides a Linux box that you connect to using an SSH client. You read lessons in the browser and run commands in your own terminal.
For the hosted option, start Chapter 1 free, confirm your email, and use the SSH connection details on your dashboard. The full 18-chapter course is $30 once; course plus eBook is $60.
Set up a fresh practice workspace
Run this block in a Linux shell. It creates a new temporary directory, adds sample files, and prints the directory's path. Keep the same terminal open for all 10 exercises. No administrator privileges are needed.
lab=$(mktemp -d /tmp/shellsamurai-practice.XXXXXX)
cd "$lab" || exit
mkdir notes logs reports
printf 'INFO login accepted\nERROR disk full\nINFO backup complete\nERROR connection refused\n' > logs/app.log
printf 'name,team\nAlex,support\nMorgan,ops\nAlex,support\n' > notes/users.csv
printf 'Capture the error before changing anything.\n' > notes/ticket.txt
printf 'port=8080\nmode=test\n' > notes/config.txt
printf 'port=8080\nmode=live\n' > notes/config-new.txt
pwd Check that your path starts with /tmp/shellsamurai-practice. before continuing. Temporary files may be cleared by your system later; keep real work elsewhere.
Exercise 1 of 10
Find your location and list the workspace
Print your current directory, then list its files and folders, including hidden entries.
Show answer and expected result
pwd
ls -la Check your work: The path starts with /tmp/shellsamurai-practice. Your listing includes logs, notes, and reports. The random suffix differs each time.
Understand pwd, cd and ls →Exercise 2 of 10
Read a support ticket
Display the contents of notes/ticket.txt without opening an editor.
Show answer and expected result
cat notes/ticket.txt Check your work: You should see: Capture the error before changing anything.
Read files with cat →Exercise 3 of 10
Find only the errors in a log
Search logs/app.log for lines that contain ERROR.
Show answer and expected result
grep 'ERROR' logs/app.log Check your work: Exactly two lines match: ERROR disk full and ERROR connection refused.
Search logs with grep →Exercise 4 of 10
Count the matching errors
Count matching log lines without counting them by hand.
Show answer and expected result
grep -c 'ERROR' logs/app.log Check your work: The result is 2. Here, grep -c counts matching lines.
Learn how filters and pipes work →Exercise 5 of 10
Extract a unique list of names
Skip the CSV header, extract the first column, and remove duplicate names.
Show answer and expected result
tail -n +2 notes/users.csv | cut -d ',' -f 1 | sort -u Check your work: The result is Alex followed by Morgan. This simple fixture contains no quoted commas; use a CSV parser for more complex CSV data.
Extract columns with cut →Exercise 6 of 10
Save a report with redirection
Write the matching error lines into reports/errors.txt, then read the report back.
Show answer and expected result
grep 'ERROR' logs/app.log > reports/errors.txt
cat reports/errors.txt Check your work: The saved report contains the same two error lines. The > operator overwrites this practice report if it already exists.
Understand pipes and redirection →Exercise 7 of 10
Find text files recursively
List every .txt file under notes, including files in any subdirectories.
Show answer and expected result
find notes -type f -name '*.txt' Check your work: The results include ticket.txt, config.txt, and config-new.txt. Their order can vary. Quotes prevent the shell from expanding the pattern first.
Find files by name →Exercise 8 of 10
Compare two configuration files
Find what changed between notes/config.txt and notes/config-new.txt.
Show answer and expected result
diff -u notes/config.txt notes/config-new.txt Check your work: The difference shows mode=test replaced by mode=live. diff exits with status 1 when files differ; that is an expected result here.
Compare files with diff →Exercise 9 of 10
Make your practice report private
Give your account read and write access to reports/errors.txt, with no access for group or others.
Show answer and expected result
chmod 600 reports/errors.txt
ls -l reports/errors.txt Check your work: The permission string begins -rw-------. Apply this only to the report you created in this workspace.
Read Linux file permissions →Exercise 10 of 10
Create an archive and inspect its contents
Archive notes and reports into practice-backup.tar.gz, then list the archive without extracting it.
Show answer and expected result
tar -czf practice-backup.tar.gz notes reports
tar -tzf practice-backup.tar.gz Check your work: The listing includes notes/ticket.txt and reports/errors.txt. Archiving does not delete the source files.
Create archives with tar →Turn individual commands into a habit
Shell Samurai gives you an ordered path through files, permissions, processes, networking, and admin commands. Connect to your hosted Linux environment over SSH and follow the quests at your own pace.
Start Chapter 1 freeNo card needed. Chapters 2–18 require a one-time purchase.
Before you start
Can I practice without installing Linux?
Yes. A hosted Linux box runs remotely. With Shell Samurai, you need an internet connection, a browser for lessons, and an SSH client on your computer. We host the box.
Is there a browser terminal on this page?
The code blocks are examples to run in a Linux terminal. Shell Samurai's practice environment is accessed through SSH from your own terminal.
Do I need sudo for these exercises?
No. You work with files owned by your account inside the temporary workspace. Hardware and service administration are separate skills to learn in an appropriate lab.
What should I learn next?
Use the Linux commands cheat sheet as a reference, try a port conflict walkthrough, or follow the guided chapters in the training app.