Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Finding Strings in Binary Files

Linux Tips by Burleson Consulting

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 list 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 trees, 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.

Finding Strings in Multiple Files

Earlier in this chapter we used find to search for recently modified files to find a file who's name we didn't know.  Now we'll see how grep can actually search the contents of files to find specific text.

Finding a File Containing a Particular Text String

$ ls ?Al
total 12
-rw-r--r--    1 tclark   authors      2229 Jan 13 21:35 declaration.txt
-rw-rw-r--    1 tclark   presidents     1310 Jan 13 17:48 gettysburg.txt
-rw-rw-r--    1 tclark   tclark        360 Feb  3 22:38 preamble.txt
$ grep -ri 'We the people' .

./preamble.txt:We the People of the United States, in Order to form a more perfect Union,

Here we use grep with the ?ri options.  The -r option causes grep to search all files in the specified directory and any subdirectories and the ?i option tells grep to ignore character case.  We then specify what string we want to search for.  Since this string is more than one word we enclose it in single quotes.  Finally we specify where we want to look, in this case the current directory.  The grep command not only outputs the line which contains the string we asked for, but also prepends it with the file which contains that line.

Find processes

In chapter 8, information will be presented that allows the location of processes by process number, user name, etc. using the ps command.  Some examples are included here as processes are a typical thing to search for.  There will be more discussion of this in chapter 8.

Finding Process Information by Process ID

Sometimes you will need to find more information about a specific process.  In that case the ?u option can be used with the ps command to specify the process number

$ ps u 4444
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
bb        4444  0.0  0.0  1548  412 ?        S    Jan20   0:00 /home/bb/bb/bin/bbrun -a /home/bb/bb/ext/bb-memory.sh

This command will search for process number 444 and return some information about it.

Find Processes Belonging to a Specific User

Using the ?u option we can look for only processes owned by a specific user.  In this example the user's name is bb.

$ ps -u bb
  PID TTY          TIME CMD
 3811 ?        00:00:00 runbb.sh
 3814 ?        00:00:00 bbrun
 3815 ?        00:00:00 runbb.sh
 3818 ?        00:00:00 runbb.sh
 3821 ?        00:00:00 runbb.sh
 3822 ?        00:00:00 bbrun
 3913 ?        00:00:00 bbrun
 4444 ?        00:00:00 bbrun


This is an excerpt from "Easy Linux Commands" by Linux guru Jon Emmons.  You can purchase it for only $19.95 (30%-off) at this link.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational