Linux Command Reference ยท Viewing and Searching Files
Linux strings command
Reference for the Linux strings command: extract printable text from binaries, set the minimum length, show offsets, and combine strings with grep.
strings scans a file for runs of printable characters and prints each run on its own line. It ignores everything else, so you can see the readable parts of a compiled program, a library, a core dump or a corrupted document: error messages, file paths, version numbers, embedded URLs.
By default a "string" is at least 4 characters long and is followed by a newline or NUL.
strings [OPTION]... FILE...
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
strings [-a] [-n LENGTH] [-t RADIX] [-e ENCODING] [-f] FILE...
| Option | Description |
|---|---|
-n LENGTH, -LENGTH |
Minimum string length (default 4). |
-a, --all |
Scan the whole file. GNU strings does this by default in current versions. |
-t RADIX |
Print each string's offset: o octal, d decimal, x hex. |
-f |
Print the file name before each string. |
-e ENC |
Encoding: s single-byte (default), S 8-bit, l 16-bit little-endian, b 16-bit big-endian. |
-w |
Include whitespace characters such as newlines inside strings. |
-s SEP |
Use SEP instead of newline between strings. |
Returns: 0 on success; non-zero if a file cannot be read.
Usage notes
- It guesses nothing. Any four printable bytes in a row count as a string, so random binary data produces some junk lines. Raise
-n(6 to 8) to cut the noise. - UTF-16 text (common in Windows files) has a NUL between letters and is invisible to the default mode. Use
-e l. - Typical uses: find which library version is embedded (
strings lib.so | grep -i version), recover text from a damaged file, see which configuration paths a program reads. - Combine with
greporsort -u; compiled programs contain thousands of strings. - Not a security tool. Obfuscated or compressed data shows nothing. It also does not tell you which strings the program actually uses.
- Security note: older
stringsversions parsed object files with the BFD library, which was risky for untrusted input. Modern GNU binutils scans raw bytes by default (the behavior of-a). Run unknown files in a sandbox anyway. - For binary layout see
od; for format identification seefile. - Different from
grep -a:grep -a text binarysearches for a known pattern;stringsdiscovers unknown text.
Related
od,xxdandhexdump,file,grep- Lessons: Hex and Binary Inspection