Module 1: First steps
Read files: cat, head, tail and less
Most troubleshooting starts by reading something: a config, a log, a message. Which command you use depends on how big the file is, and which part you care about.
● Runs 100% in your browser. Nothing here can harm a real system.
Step 1 of 6
Print a whole file
cat prints a file from start to end. That's best for short files.
Your task
Print todo.txt.
guest@ohsudo: ~ — Ubuntu 24.04
Starting the terminal…
What you'll practice
- Print a whole file.
catprints a file from start to end. That's best for short files. - The start of a file.
headprints the first lines of a file, 10 by default.-nchooses how many. - The end of a file.
tailprints the last lines. It's the one to use on logs, since the newest lines are at the end. On a real system,tail -fkeeps showing new lines as they arrive. - Page through a long file.
lessshows a long file one screen at a time. On a real system you scroll with the arrows, search with/, and leave withq. In this playground, it just prints the file. - Which system is this?.
/etc/os-releasesays which Linux you're on. It's worth checking first, as package managers and file locations differ between families. - A protected log. Many logs can only be read as root.
sudoruns one command with those rights. Debian and Ubuntu write general system messages to/var/log/syslog. Many logs can only be read as root.sudoruns one command with those rights. RHEL, Rocky and AlmaLinux write general system messages to/var/log/messages.