Learn › Linux Foundations
Reading Files
Look inside files without changing them. Print, page, search, count, and identify file contents and metadata.
Labs in this module
- cat - Read any short file with cat: dump it whole, number the lines with -n, expose the invisible newlines and tabs with -A (and spot a file with
- head - Take a first look at any file with head: the first 10 lines by default, an exact line count with -n, or a byte count with -c. Practice on th
- wc - Measure any file with wc: lines, words, and bytes in one shot, or isolate one with -l, -w, -c, or -m. Meet the missing-newline trap where wc
- more - Page through a file too long to dump with more, the simple older pager: open it with more <file, move forward with Space, search forward wit
- hexdump - Read any file one byte at a time with hexdump. Learn the canonical -C layout (offset, 16 hex bytes, and an ASCII gutter), then meet the byte
- xxd - Crack open a binary file with xxd: a clean hex dump with an offset, byte pairs, and an ASCII gutter, then -l to read only the first bytes an
- df - Read a whole disk at a glance with df. The six columns, human units with -h, one filesystem by path, and the one df output that is identical
- du - Weigh files and folders on disk with du. See why on-disk blocks differ from exact bytes (du -b matches wc -c), read sizes with -h, weigh sev
- stat - Pull a file's record card with stat: the exact Size in bytes, owner, permissions, inode, and the three timestamps, plus cards for binaries a
- file - Identify what a file truly is by its contents, not its name, with the file command. Tell ASCII text from raw data from a directory, check se
- tac - Print any file bottom to top with tac, cat spelled backwards. Reverse a log so the newest line is first, see the one-line-file edge case, an
- tail - Read the end of any file with tail. The default last 10, choose a count with -n, start from a line with -n +N, and grab bytes with -c, all i
- less - Page through a file too long to dump with less, the interactive pager. Open it with less, add -N for line numbers or +/pattern to land on a
- Operation Signal Intercept - The Reading Files module capstone mission. Drill cat, tac, head, tail, less, more, wc, file, stat, du, df, hexdump, and xxd in one hands-on