Use cat to display or combine whole files, head to inspect the beginning, and tail to inspect the end or watch new output as it appears. These commands show or stream content; they do not edit, move, or delete files.
Which command should you use?
| Command | What it displays | GNU default | Example |
|---|---|---|---|
cat |
All supplied input; can display several files in sequence | All input | cat notes.txt |
head |
The beginning of a file | First 10 lines | head -n 5 notes.txt |
tail |
The end of a file, or new content as it is appended | Last 10 lines | tail -n 20 notes.txt |
The defaults in this table are those documented for GNU Coreutils 9.11; other Unix-like systems may use different options or behavior. See the GNU cat manual and the GNU head and GNU tail manuals for details.
As an Amazon Associate I earn from qualifying purchases.
Display a whole file with cat
Run cat followed by a filename to write the file’s contents to standard output, which normally appears in your terminal:
cat notes.txt
With multiple filenames, cat writes their contents one after another:
#1 Best Overall
cat part1.txt part2.txt
It does not add a separator between files. If the first file does not end with a newline, the next file’s content can begin on the same displayed line. Use cat for short files or when you intentionally want to combine input streams; for a long file, showing only a portion with head or tail is usually easier to inspect.
With no filename, or with - as an input name, GNU cat reads standard input. For example, some-command | cat passes that command’s output through to the terminal.
Rank #2
Useful GNU cat display options
cat -n notes.txtnumbers every output line.cat -b notes.txtnumbers nonempty lines.cat -E notes.txtmarks line endings.cat -T notes.txtmakes tab characters visible.cat -v notes.txtdisplays many nonprinting characters in a visible form.cat -s notes.txtsqueezes repeated adjacent blank lines into one.
These options affect what is shown, not the contents saved in the file.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Preview the beginning with head
Use head when you want a quick look at the first lines, such as the opening of a text file or log:
Rank #3
head notes.txt
GNU head displays the first 10 lines by default. Specify a different line count with -n:
head -n 5 notes.txt
This prints up to the first five lines. When given multiple filenames, GNU head prints a heading identifying each input file.
Rank #4
Inspect the ending or follow updates with tail
Use tail to see the most recent lines at the end of a file:
tail notes.txt
GNU tail shows the last 10 lines by default. To request more or fewer, use -n:
Best Value
tail -n 20 notes.txt
To keep displaying content as it is appended, use follow mode:
tail -f /var/log/example.log
This is useful for observing a log while another process writes to it. Stop the running command with Ctrl+C. Follow behavior and available options can vary by implementation; consult the manual installed on your system if the file is replaced or rotated and you need specific follow behavior. With multiple input files, GNU tail prints a heading identifying each one.
Do these commands manage or change files?
In this context, “manage” means inspect or stream file contents. cat, head, and tail write output; they are not substitutes for an editor and do not provide general file operations such as copying, moving, or deleting. The GNU Coreutils basic operations documentation treats those operations separately from displaying whole files or parts of files.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Check options on your Linux system
The examples use common GNU forms, but Linux distributions and other Unix-like systems may ship different implementations. If an option is rejected or behaves differently, check the local manual pages with man cat, man head, or man tail. The Debian Bookworm cat(1) manual is one example of distribution-specific documentation.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




