Run executable files on linux

How to run binary file in Linux

I have a file called commanKT and want to run it in a Linux terminal. Can someone help by giving the command to run this file? I tried ./commonRT but I’m getting the error:

"bash: ./commonrt: cannot execute binary file" [blackberry@BuildMc MainApp]$ ls -al commonKT -rwxrwxr-x. 1 sijith sijith 10314053 Feb 27 16:49 commonKT 

Assuming the problem isn’t just a mixup over names ( commonrt vs commonKT ), what does the command file commonKT /bin/sh say? If it gives two different architectures (perhaps one for ARM and one for Intel), then that’s why you can’t run the ARM one on an Intel machine.

In addition of using file , I also suggest using ldd ; perhaps the dynamic linker or some core shared library is different or missing.

Why does this question have so many upvotes? It contains so many variants of the questioned filename (commonrt, commonKT, commanKT, commonRT), that it’s not even clear what was asked. Also interesting: Does the last comment of Sijith mean that it is answered? And why did user1978011 receive bountys?

13 Answers 13

To execute a binary, use: ./binary_name .

bash: ./binary_name: cannot execute binary file

it’ll be because it was compiled using a tool chain that was for a different target to that which you’re attempting to run the binary on.

For example, if you compile ‘binary_name.c’ with arm-none-linux-gnueabi-gcc and try run the generated binary on an x86 machine, you will get the aforementioned error.

To execute a binary or .run file in Linux from the shell, use the dot forward slash friend

and if it fails say because of permissions, you could try this before executing it

 chmod +x binary_file_name # then execute it ./binary_file_name 

The volume it’s on is mounted noexec .

🙂 If not typo, why are you using ./commonRT instead of ./commonKT ??

It is possible that you compiled your binary with incompatible architecture settings on your build host vs. your execution host. Can you please have a look at the enabled target settings via

on your build host? In particular, the COLLECT_GCC_OPTIONS variable may give you valuable debug info. Then have a look at the CPU capabilities on your execution host via

cat /proc/cpuinfo | grep -m1 flags 

Look out for mismatches such as -msse4.2 [enabled] on your build host but a missing sse4_2 flag in the CPU capabilities.

Читайте также:  Линукс минт пароль при входе

If that doesn’t help, please provide the output of ldd commonKT on both build and execution host.

@craq I see that you gave me your bounty, thanks! Can you please give some info what the error was about?

This is an answer to @craq :

I just compiled the file from C source and set it to be executable with chmod. There were no warning or error messages from gcc.

I’m a bit surprised that you had to ‘set it to executable’ — my gcc always sets the executable flag itself. This suggests to me that gcc didn’t expect this to be the final executable file, or that it didn’t expect it to be executable on this system.

Now I’ve tried to just create the object file, like so:

$ gcc -c -o hello hello.c $ chmod +x hello 

( hello.c is a typical «Hello World» program.) But my error message is a bit different:

$ ./hello bash: ./hello: cannot execute binary file: Exec format error` 

On the other hand, this way, the output of the file command is identical to yours:

$ file hello hello: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped 

Whereas if I compile correctly, its output is much longer.

$ gcc -o hello hello.c $ file hello hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=131bb123a67dd3089d23d5aaaa65a79c4c6a0ef7, not stripped 

What I am saying is: I suspect it has something to do with the way you compile and link your code. Maybe you can shed some light on how you do that?

Источник

Running executable files on Linux [duplicate]

I have made my Python script executable with chmod +x and now I can run it from the terminal with ./ prefix (./script_name). What exactly does this prefix mean? Why is it needed to run an executable file?

3 Answers 3

Like any other program, a shell is also a program which is waiting for input. Now when you type in command1 arg1 arg2 . , the first thing a shell does is to try to identify command1 from among the following:

  1. a function (try typeset -f in Bash shell)
  2. an in-built command (such as type )
  3. a shell alias (try alias in Bash shell)
  4. a file that can be executed
Читайте также:  Check if module is installed linux

Now the question concerns the last point a file that can be executed. A Unix kernel will need absolute path of an executable file in exec() system call (see man exec ).

To obtain the absolute path of a file, the shell first looks up the command in directories specified in $PATH variable.

So if you specify the relative path such as ../abc/command1 or ./command1 then Bash will be able to find that file and pass it to exec() system call.

If all the above four steps fail to locate the command1 input to the shell, you will get:

$ command1 command1: command not found 

However, if the file’s absolute path is resolved, but it is not executable, you get:

$ command1 bash: ./command1: Permission denied 

Источник

How to run exe file in Ubuntu [duplicate]

If the .exe file is a windows executeable, you can’t run it directly in Ubuntu (or other Linux’s). Either you should install Wine and run it through that, or find a utility in Ubuntu that does the same as the windows one.

Could be a slight case of the XY-problem (meta.stackexchange.com/questions/66377/what-is-the-xy-problem). If you want to convert a wav-file to raw PCM data for processing in Matlab, you could use a linux-tool like sox instead: stackoverflow.com/questions/9383576/…

Is WAV2RAW.exe the only EXE program you want to run, or do you have several other DOS / Windows / .NET programs?

I’m relatively sure that Matlab (and its open-source clone Octave) have native functions to parse WAVE headers and data as well as to write raw PCM data since I used them in the past. Those would obviate the need for an external conversion application unless the PCM data doesn’t fit into main memory.

2 Answers 2

I think you should use Wine.

sudo apt-get install wine wine dir/WAV2RAW.exe 

Or Mono if you know that exe is .NET application:

sudo apt install mono-runtime mono dir/WAV2RAW.exe 

You don’t need to chmod . Besides that, it’s worth noting that not all software runs under wine. YMMV.

You seem to have added the chmod line according to my comment. However, I think it is only necessary if you want to run the .exe file directly, i.e. without prepending wine to the command line – like OP wants to. I haven’t tested it with Wine but it behaves this way with .NET exe files ( mono my.exe or chmod +x my.exe && ./my.exe ) or even shell scripts ( sh script.sh or chmod +x script.sh && ./script.sh ).

Читайте также:  Настройка тонкого linux клиент

@Melebius that works because Wine registers itself in binfmts when installed from the official Ubuntu package.

Источник

Run Binary Files on Linux

Run or Execute Binary (.bin) Files on Linux

This tutorial intends to teach you to Run or Execute Binary (.bin) Files on Linux.

A binary file is a file stored in binary format. A binary file is computer-readable but not human-readable. All executable programs are stored in binary files, as are most numeric data files.

The binary file is the most common type of computer file, and it can be found on all types of computers, including Windows PCs, Macs, Linux systems, and mobile devices such as smartphones and tablets. Binary files are also known as executable files or object codes.

The advantage of using binary files is that they can be sent over the Internet more quickly than text-based or other types of non-binary files.

Steps To Run or Execute Binary (.bin) Files on Linux

You can use the following methods to execute your “.bin” files:

Run .bin Files Via CLI on Linux

Those who are comfortable with the command line interface can use the following Linux Commands.

When you have downloaded your binary file in your Linux distro, you need to change the permissions of the specific “.bin” file using the “chmod” command. For example:

Execute .bin Files

At this point, you can easily run your binary file by using the command below:

This will run your downloaded binary file.

Run .bin Files Via GUI on Linux

Those who are comfortable with the graphical user interface can use the following steps.

First, you need to open the directory where the desired “.bin” file is saved or downloaded on your Linux distro.

Then, right-click on the file and choose the “Properties” option.

The “Lato-Regular.bin Properties” window will be opened.

From there choose the “Permission” icon located in the menu bar of the “properties” window. Tick the highlighted checkbox “Allow executing file as a program”.

Finally, double-click on the “.bin” file and install it.

Conclusion

At this point, you have learned to Run or Execute Binary (.bin) Files on Linux.

Hope you enjoy it. You may be like these articles too:

Источник

Оцените статью
Adblock
detector