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.
How to check the string version in Ubuntu
To check the version of this tool use the following command:
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:
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:
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:
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.
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:
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:
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:
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:
For help on the strings command, run the below given command in your terminal:
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.