How to use the string command in Ubuntu

Checking a binary or executable file to extract human readable text is not something we do in our daily life, but what if asked to? In Ubuntu, the “Stringscommand allows you to display all readable characters in a binary / executable file. The “Strings”Command is mainly used to determine the file type, but can also be used to extract text. For example, you saved a file in an unusual binary format; You can change the text you have entered in this file with the “Stringscommand without encountering non-printable characters.

One question may come to mind: Why are we adding text to the executables? Many developers have packaged the binaries when software or applications are released. However, it is an excellent idea to include ASCII text in this binary file. It is beneficial for developers and users to have a better understanding of the executable file. As a result, the “strings” command helps you determine the content of these non-text files.

In this article we will talk about it how to install and use strings on their Ubuntu System. So let’s go ahead!

How to install strings in Ubuntu

First of all you have tobinutils“Package for the use of the”Strings”Command on Ubuntu. This package contains various programming tools for creating and managing binary files, profile data, libraries, object files, and assembly source code.

$ sudo suitable To install binutils

How to check the string version in Ubuntu

To check the version of this tool use the following command:

$ Strings -Execution

How to use the string command in Ubuntu

The primary use of the strings command is to extract strings. To do this, enter the file name as input and run this command in your Ubuntu terminal. In our system we have a binary / executable file called “Sample file“. We will use this binary in all of our examples.

The strings command extracts all of the strings present in our specified file. Now run the command given below to check its function:

$ Strings Sample file

This is how you define the minimum string length in the Strings command

In the strings command, the Default value of the minimum string length is set to 4th, ie this command only prints the character string with a minimum length of 4. You can change this limit value by pressing the “-n”Option in the string command. This “-n”Option takes a numeric value that represents the limit of the character strings.

We have hired 3 as the minimum length of strings in the example given below. Executing this command prints the strings with a minimum length of three characters:

$ Strings -n 3 Sample file

How to print the offset of a string with the strings command

By doing String command, you can use the “-T”Option to display the Offsets of strings. This option requires you to enter a single character that defines the base of the offset. You can use:

  • D.” to the Decimal
  • x” to the hexadecimal
  • Ö” to the octal

Now write the command given below to print the decimal offset of the strings of your executable file:

$ Strings -T d sample file

How to scan an entire file with the Strings command

The “Strings”Command may or may not scan the entire input file as it depends on its configuration. Use the “-a”Option to ensure that the strings command scans an entire binary file that is present on your system.

$ Strings -a Sample file

How to change the default separator in the strings command

From the example above, you can see that the Standard character string separator is the New line. You can the “-S”Option in the strings command to change these settings. For example we will state ““As a String separator in this command:

$ Strings -S Sample file

Executing the command will show you the following output:

How to Search Multiple Files with the Strings Command

Wildcards are used to search for specific files. The “*“Character represents multiple values ​​in the strings command, and”?”Is used to indicate a single value. We will search through all binary files that are included in the “/Container”Directory with the“*”Placeholder in the following example. Here too we have the “-if”Option because the strings command lists the extracted result from multiple binary files with the filename at the beginning of each line.

Another functionality of the Strings command given below is that it sends the extracted result to the “grep”Command with the“[|]“Pipe operator. This part of the command looks for the strings with the “Copyright ©” Word:

$ Strings -F /container/ * | grep Copyright ©

Running the given command will show you the following output:

How to search in system RAM using the Strings command

The Strings commands can be used for various other operations besides extracting strings from binary and executable files. It allows us to check the RAM in our system. The sudo privilege is required for this, as we click on “/ dev / mem“, Which contains the blueprint for the main memory of our system. The “fewer”Is used to limit the output of this string command:

$ sudo Strings /developer/mem | fewer

How to open the manual of the Strings command in Ubuntu

If you want to check the manual of the Strings command, write this command in your Ubuntu terminal:

$ man Strings

For help on the strings command, run the below given command in your terminal:

$ Strings -Help


If you want to check the contents of a binary file, then in Ubuntu “Strings”Command is used. It extracts text fragments from the binary files, also known as “Strings“. This article has been demonstrated to you How to use the strings command in Ubuntu. We have also explained various examples of this. Try them out to better understand the strings command.

Related Posts