🐧 Linux / Shell Scripting
Beginner
How do you view the contents of a file?
Answer
Several commands display file contents. cat filename prints the entire file. less filename shows it page by page (press q to quit, / to search) — preferred for large files. more filename is an older pager. head -n 20 filename shows the first 20 lines. tail -n 20 filename shows the last 20 lines. tail -f filename follows the file in real time — essential for log monitoring. tac filename prints lines in reverse order.
Previous
How do you move or rename a file in Linux?
Next
What is the difference between absolute and relative paths?