Viewing Content
Summary
This note is a quick reference for reading files, logs, and command output in the terminal. These commands are used constantly when checking configuration, inspecting text, and following logs during troubleshooting.
Commands
| Command | Purpose |
|---|---|
cat file.txt | print the whole file to the terminal |
less file.txt | open a scrollable viewer for longer output |
head file.txt | show the first lines of a file |
tail -f logfile.log | follow a log file live as new lines appear |
echo "text" | print text or variable output to the terminal |
Example usage
less /etc/os-release
head -n 5 file.txt
tail -f app.log
echo "$HOME"Notes
lessis usually safer thancatfor large filestail -fis one of the most useful commands for watching logs in real timeechois often used to test shell values, output, or simple text formatting
Related
- Back to Linux Reference
- Search
- [File management](File management)
- [Process management](Process management)