🐧 Linux / Shell Scripting
Beginner
How do you display the first few lines of a file?
Answer
Use head filename which shows the first 10 lines by default. head -n 20 filename shows the first 20 lines. head -c 100 filename shows the first 100 bytes. Useful for inspecting large files, checking CSV headers, or verifying the start of log files. Combine with other commands: cat /etc/passwd | head -5 shows only the first 5 lines of passwd. In scripts, head -1 file extracts the first line (e.g., reading a config value or CSV header).