Text and processing

The strings command

Extracts the readable text inside a file, even if it is binary.

Syntax

strings [-n N] <archivo>Try it in the terminal →

Most useful options

-n, --bytes <longitud>Minimum length of each string. The default is 4 characters
-t, --radix <o|d|x>Puts each string's offset in the file in front: o octal, d decimal, x hexadecimal
-f, --print-file-namePrints the file name before each string. Useful when you scan several at once
-a, --allScans the whole file, not only its data sections. Depending on how strings was built, it may be the default
-e, --encoding <s|S|b|l|B|L>String encoding: s 7-bit characters (default), S 8-bit, b and l 16-bit, B and L 32-bit
-w, --include-all-whitespaceTreats any whitespace as part of a string, including newlines and carriage returns
-s, --output-separator <texto>Changes the separator between strings, which by default is a newline
-d, --dataOnly strings from initialized, loaded data sections. It can reduce the noise

Copy-ready examples

$ strings /etc/passwdthe strings in the accounts file. A quick test: on a text file it returns almost everything.
$ strings -n 8 /usr/bin/lsonly strings of 8 characters or more, which are usually messages and paths rather than noise.
$ strings -t x /usr/bin/ls | grep -i usagehexadecimal position of each string that contains 'usage'.
$ strings -f -n 6 *.so* | grep -i versionversion strings in the shared libraries, with the file name in front.
$ strings -e l salida.bin16-bit strings in little endian order, such as UTF-16 text in some formats.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
strings: 'informe.bin': No such fileThe file does not exist or the name is misspelled. strings carries on with the other files and ends with an error code.List the folder with ls and copy the exact name.
strings: Warning: 'Documentos' is a directorystrings scans files, not folders. Passing it a directory only gives this warning.Give the exact file inside the folder, for example Documentos/nota.bin.
strings: invalid integer argument abcThe value of -n is not a number. It is read in base 0, so prefixes such as 0x are also accepted.Write the length as a number: strings -n 8 file.

Typical mistakes

  • By default only strings of 4 characters or more appear: a short text such as '1.2' will not show up unless you lower -n.
  • On big binaries the dump can be huge: filter it with grep or use head so it does not flood the screen.
  • What strings shows is text, not meaning: among the strings there is code noise, and a message or a path does not explain how the program works.

Differences from similar commands

  • file: says what kind of file it is. strings extracts the text inside, without interpreting the structure.
  • xxd: shows all the bytes in hexadecimal. strings shows only the readable text sequences.
  • grep: searches a pattern in the content. It is often combined with strings: extract the text first, then filter it.
  • strings -o: in GNU it works like -t o (octal); in other implementations, like -t d (decimal). On Debian and Ubuntu it comes from binutils, with the GNU behaviour.

Related commands

FAQ

Why do so many meaningless lines appear?

Because strings takes any run of printable characters at the minimum length as a string, and in a binary some code bytes happen to be letters too. Raise -n to filter them out.

How do I extract UTF-16 text?

With -e l (16-bit, little endian) or -e b (big endian). For 32-bit, use -e L or -e B.

How do I search strings in several files at once?

Pass several names or a wildcard, and add -f to see which file each string comes from: strings -f *.bin.

More Text and processing commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course