Published: July 22, 2026
Read: 8 min
In: Technology & Development

Written by

Reviewed by

Last updated: July 24, 2024

Expert verified

SVG Image

TL; DR

To run binary files in Linux, you can try any of the two methods below:

  1. Terminal app: Execute the chmod + x filename.extension command to make the file executable and then enter ./filename to run the script in the Terminal.
  2. GUI: Right-click on the binary file, select Properties, and check the box that says Allow executing file as program. Then, double-click the executable file to run it in a new window.

Check out my detailed and step-by-step guide below to easily run binary files on your Linux-based systems.

Running binary files in Linux can seem confusing if you’re new to it. Many users struggle with getting these files to work correctly. In this post, I’ll show you how to run binary files using both the terminal and GUI. You’ll also learn key security practices to keep your system safe from potential threats. By following these steps, you’ll gain confidence in handling binary files and ensure your Linux system runs smoothly.

What are Binary Files?

A binary file is a type of file that contains data in a format that a computer can read but humans usually cannot. Unlike text files, which store data as plain text that you can read, binary files store data as a series of ones and zeros.

This data can represent anything from an image to an executable program. Binary files are efficient for computers to process because they are in a format that the computer’s hardware understands directly.

Differences Between Binary and Text Files

Aspect Text Files Binary Files
Format Plain text using characters like letters, numbers, and symbols. Each character is represented by a specific code (e.g., ASCII). Binary format, which is a series of ones and zeros. Not meant to be read by humans directly.
Readability Human-readable; can be opened and read using simple text editors like Notepad or Vim. Not human-readable; opening in a text editor shows random characters and symbols.
Use Cases Used for documents, source code, and configuration files (e.g., .txt, .csv, .html). Used for executable programs, compiled code, and complex data storage (e.g., .exe, .bin, .png).
Size and Efficiency Usually larger due to more space needed for characters; easy to edit but less efficient for complex data. More compact and efficient; stores data in the format the computer uses directly, making them faster to read and write.

How to Run Binary Files in Linux

To run binary files in Linux, you can use either the terminal or the GUI. In the terminal, navigate to the file’s directory, make it executable with chmod +x filename, and run it with ./filename. Alternatively, in the GUI, locate the file in the file manager, right-click, select Properties, check Allow executing file as program, and double-click the file to run it.

Here, I am going to explore both of these ways to run binary files on your Linux system.

1. Run Binary Files Using the Terminal

The most common way to run a binary file in Linux is through the Terminal app. Here are the step-by-step instructions to create and run the binary file in Linux. However, you can skip the creation process if you already have a binary file and directly jump to step 4.

  1. Open the nano text editor in the Terminal app using the command below.

nano
  1. Copy and paste the following code into the text editor:

#!/bin/bash  # Create a binary file echo -ne "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x62\x69\x6e\x61\x72\x79\x20\x66\x69\x6c\x65" > binary_file  # Read the binary file and display the output cat binary_file
  1. Press Ctrl + O  to save the file with a .sh extension and press Enter. After saving the file, press Ctrl + X to exit the nano editor.
create binary files using the terminal
  1. Make the file executable by running the command:

chmod +x binary_script.sh
  1. Run the script in the terminal and press Enter.

./binary_script.sh
  1. The script will create a binary file called binary_file in the same directory.
create binary file in same directory
  1. If the output disappears from your Terminal interface, add a sleep command after the cat command to pause the script for a few seconds before exiting. For example, you can add the line sleep 10 after cat binary_file to pause the script for 10 seconds before exiting.
pause script for 10 seconds before exiting

2. Run Binary Files Using the GUI

If you prefer not to use the terminal, you can also run binary files using the GUI. To do this, follow these steps:

  1. Head to the directory where the executable binary file is located using the file manager.
head to executable binary file location
  1. Right-click on the binary file and select Properties.
select properties by right clicking binary file run binary files
  1. In the Permissions tab, check the box that says Allow executing file as program.
allow executing file as program in permission tab
  1. Now, close the properties window and double-click on the binary file to run it in a new window.

Essential Security Practices for Running Binary Files in Linux

Running binary files on Linux can be risky if you don’t take the right steps. By following some key practices, you can protect your system from potential threats. Here are five important security measures to follow:

  • 🔒 Use Security Tools: Employ tools like AppArmor or SELinux to enforce strict security policies. These tools help restrict what a binary file can do, adding an extra layer of protection to your system.
  • 🔒 Download from Trusted Sources: Always download binary files from official websites or trusted sources. Avoid unknown or suspicious sites to reduce the risk of malware.
  • 🔍 Verify File Integrity: Check the file’s integrity using checksums like md5sum or sha256sum. Comparing the checksum with the one provided by the source ensures the file hasn’t been tampered with.
  • ⚙️ Check File Permissions: Ensure the binary file has the correct permissions. Use chmod +x filename to make it executable, and avoid giving unnecessary permissions that could lead to security risks.
  • 🛡️ Scan for Malware: Use antivirus tools like ClamAV to scan binary files for malware. Regularly scanning files helps detect and remove malicious code before it can harm your system.

Summing Up

In this article, I’ve covered the methods to run binary files in Linux using both the terminal and the GUI, providing step-by-step instructions for each approach. I also highlighted essential security practices to follow, such as using trusted sources, verifying file integrity, and employing security tools like AppArmor or SELinux to protect your system.

If you found this guide helpful, you might want to explore other relevant topics to deepen your Linux knowledge:

Frequently Asked Questions

What are Binary files?

Binary files store data in a format that is machine-readable, such as computers or microcontrollers. They are typically used to store executable code, images, audio, video, and other types of data in zeros and ones. This format allows binary files to be much smaller than text files and allows them to be accessed much more quickly.

How do I know if a binary file is malicious?

Unfortunately, it can be difficult to determine if a binary file is malicious or not, especially if the file comes from an unknown or untrusted source. However, there are some steps you can take to minimize the risk of running a malicious binary file. Always run binary files from trusted sources, use antivirus software to scan your system for malware, and keep your system and software up to date with the latest security patches.

What are the types of Binary files?

There are several types of binary files, including:
– Executable files: These are files that contain machine code that can be executed by the operating system. Examples include programs, scripts, and compiled code.
– Libraries: These are collections of precompiled functions and subroutines that can be used by other programs.
– Object files: These are intermediate files that are generated during the compilation process and contain machine code that has not yet been linked to other files.

How can I optimize a binary file for my Linux system?

Optimizing a binary file for your Linux system can help it run more efficiently and effectively. Some tips for optimization include using a package manager to install dependencies, compiling the binary file specifically for your Linux distribution, and removing any unnecessary code or features from the binary file.

Can I run 32-bit binary files on a 64-bit Linux system?

Yes, you can run 32-bit binary files on a 64-bit Linux system using the ia32-libs package or a similar tool. However, keep in mind that running 32-bit binary files on a 64-bit system can introduce compatibility issues and may require additional configuration.

What are the ways to create and run binary files?

There are several ways to create binary files. However, some popular ways to create them are:
– Compiling source code: Converting human-readable code into machine code that can be run directly on the operating system.
– Assembly: A low-level programming language that is used to write programs directly in machine code. Assembly language programs are usually stored in binary files.
– Image, audio, and video encoding: These files are stored in binary format to reduce their size and allow for faster access.

If a binary file fails to run in Linux, what are the possible actions to take?

If a binary file does not run in Linux, there are several things you can try. First, make sure that the file is executable and that you are running it correctly. If the file still does not run, check the documentation for the binary file to see if any additional dependencies or libraries are required. If all else fails, you may need to seek assistance from the software developer or a Linux support forum.