You can create files. Now look inside one.
cat — print a file
cat shopping.txt
milk
bread
coffee
That is the whole command. cat reads the file and prints it into the terminal, then gives you your back.
Nothing is opened and nothing can be edited, which means nothing can be accidentally saved either. cat is purely a read.
Note
The name is short for concatenate, because its original job was joining files together. cat a.txt b.txt prints both in a row. Printing one file turned out to be the far more common use, and the name stuck.
Quick check
What is the difference between ls and cat?
cat -n — numbered lines
cat -n shopping.txt
1 milk
2 bread
3 coffee
Numbers make it possible to point at a spot. “The bug is on line 42” is a sentence you can say to a colleague or to an AI agent, and both will know exactly where to look.
Quick check
Why would you add -n when reading a file?
When cat is the wrong tool
cat prints the whole file. On a three-line shopping list that is perfect. On a ten-thousand-line log it dumps everything and scrolls the useful part off the top.
For big files:
head file— the first ten linestail file— the last ten lines (usually what you want in a log)less file— page through it a screen at a time
Both head and tail take -n to choose how many: head -n 3 file.
Tip
In less, press Space to go down a page and q to quit. Nobody discovers q on their own, and getting stuck in a pager is a genuinely common first-week experience. Now you know.
Quick check
You want the last 20 lines of a long log file. What do you run?
Try it
The folder has two small files in it.
ls— see what is there.cat shopping.txt— read it.cat -n shopping.txt— read it again, numbered.
Then, if you like, try cat shopping.txt readme.txt to see both printed one after the other.