Viewing strings of text in binary files on Linux and UNIX

If a user encounters a binary file and does not know what it is used for or where it came from, they may gain some insight into its origins and use by searching for character strings within the file. If the cat command is used to view a binary file, the user will get a screen full of garbage that will more often than not change the display characteristics. Instead, the strings command should be used, as demonstrated in the following examples:

Find All Strings in the Binary File

$ strings echo
/lib/ld-linux.so.2
libc.so.6
stdout
getopt_long
__fpending
getenv
...
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%s (%s) %s
Written by %s.
%s %s
memory exhausted

Again the above output has been abbreviated to save space, but you can see that there is some useful information here. Just knowing that “This is free software” and that it is copyrighted by the Free Software Foundation can give you some great insight on where this came from and why it might be there.

Finding Occurrences of a String in a Binary File

Here we show how the output of the strings command can be piped into the grep command to look for specific words within a binary file.

$ strings echo|grep GLIBC
GLIBC_2.3
GLIBC_2.1.3
GLIBC_2.1
GLIBC_2.0
GLIBC_2.2

This shows how grep can be used to limit the output of a command to only lines that contain certain text.

Easy Linux CommandsFor more tips like this check out my book Easy Linux Commands, only $19.95 from Rampant TechPress.

Buy it now!


unix, linux, text, search, find

EditPlus for SQL Editing and More

EditPlus in actionWhile there are many text editors out there offering a broad set of features my favorite right now is EditPlus.

EditPlus is a Windows shareware application designed for text, HTML, Java, PHP, etc. It’s very thin requiring little (nearly no) load time and has many great features such as:

  • Syntax hilighting for many languages
  • EditPlus on Windows right-click
  • FTP and SFTP integration
  • Templates
  • Line Numbering
  • Column Selection
  • Optional Spell Checker

The list of features is long and every revision brings more. Check out the Features page for more.

I’ve been using the Oracle 9iR2 syntax file from the user files section of EditPlus.com and it seems to pick up all the SQL and PL/SQL syntax I use, although many other syntax files exist and you could always make your own.

As mentioned above, EditPlus is shareware. A single user license is only $30, and with discounts for buying in bulk there is no reason not to pay, but for now, download it, try it, and see why you can’t live without it.

Thanks to Zach for showing this to me a couple years ago.

text, text editing, editing, editor, edit, sql, plsql, pl/sql, sftp, ftp, notepad, wordpad, oracle, unix, php, perl, programming, database programming, dba, database administration, systems administration, c, c++, java, javascript, css, html