- How to run an .exe from linux command prompt
- Executes Under Windows
- Execute Under Linux
- Executing a Linux executable on Linux
- Executing a Windows executable on Linux
- How to Run Files in Linux
- Using a File Manager
- Using the Terminal
- Expert Q&A
- Tips
- You Might Also Like
- How to run binary file in Linux
- 13 Answers 13
How to run an .exe from linux command prompt
but if it’s really a Windows program, you will need to install «wine», then do:
but only some Windows programs will work under wine.
This anwswer is combining other answers in to this question into one.
The info.exe file will either execute under Linux or Windows, but not both.
Executes Under Windows
If the file is a windows file, it will not run under Linux on it’s own. So if that’s the case, you could try running it under a windows emulator (WINE). If it’s not compatible with wine, then you won’t be able to execute it under Linux.
Before you can start, you will need to install wine. The steps you need to install wine will vary on the linux platform you are on. You can probably google «Ubuntu install wine», if for example, you’re installing ubuntu.
Once you have wine installed, then you’d be able to execute these commands.
Execute Under Linux
if you know this file to run under linux, then you’ll want to execute these commands:
Change to your abc directory
Then you’ll want to change permissions to allow all users to execute this file (a+x).
you could also allow just the user to execute (u+x)
Launch the program, the ./ tells the command line to look in the current path for the file to execute (if the ‘current’ directory isn’t in the $PATH environment variable.
«you could try running it under a windows emulator (WINE).» WINE does stand for «Wine Is Not an Emulator».
My comment was meant to be both a joke a a proposition for an edit. AFAIK Wine basically replaces windows calls for POSIX equivalents, so whoever named it was not ironic, that is WINE is indeed not an emulator.
you can’t 🙂 exe is Microsoft only. now if you had a linux executable you could do:
cd folder chmod +x file ./file
This is false in general. Many Windows and DOS EXEs can be run on Linux using emulators such as wine or dosbox .
@Royi probably «yes», but that depends on how simple we’re talking. But wine should also do your trick.
On Linux you give the file executable permissions. It isn’t the extension that determines whether or not it can be executed (as on windows.)
Assuming you have a valid file that can be executed in Linux, (not a windows/dos file) do this:
cd abc chmod a+x info.exe ./info.exe
Note that you need the leading ./ for the shell to find the file in the current directory!
This really belongs on superuser though.
The first line changes the directory, the second line tells linux it is executable, the third runs the program.
I recently wanted to run some old MSDOS .exe files and I could just use dosbox. On Ubuntu it was just
.exes are generally Windows executables, not linux ones. To run those, use something like WINE.
Otherwise, to run a Linux executable, there are many ways, e.g.:
- cd abc; ./info.exe
- ./abc/info.exe
- /full/path/to/abc/info.exe
- Add «abc» to your PATH, then just run it as a normal command.
I struggled so much until I found this website and used the ‘terminal’ tips section at the bottom of the page: winehq.org/download/ubuntu
Wine is a program that you can install, which allows you to run .exe files on linux.
(go to the directory of your file: /cd (ex: Desktop/) And to open your .exe file:
If you have any problems with wine, you can do wine —help .
Here is how to run an executable file in Linux:
- open terminal with ctrl + alt + T : sudo apt-get update
- install Wine: sudo apt-get install wine
- go to the directory in which your .exe file is placed by changing directory: cd /Desktop
- wine filename.exe
Hit enter and your .exe file will be executed.
Executing a Linux executable on Linux
If the executable is a Linux executable, you need to make sure that your shell can find it. Here are some ways how to do that.
But first, make sure it’s executable. You can check whether the x (executable) flag is set using ls -l abc/info.exe and you can set it with chmod +x abc/info.exe .
- Run it with relative path, in your example: abc/info.exe .
- Run it with absolute path, for example: /home/username/abc/info.exe (depends on where it actually is)
- Place the binary in a directory that is part of the PATH that is searched by the shell to find binaries. For example, cp abc/info.exe ~/bin/ . If ~/bin is part of PATH , you can now run info.exe without qualifying it.
- Make the directory that contains the binary part of the PATH , for example, export PATH=~/abc:$PATH . Note that this is for the current shell only, unless you add this line to your .bashrc or .profile
Executing a Windows executable on Linux
If the executable is a Windows executable, you need to install wine . Then you can run it using wine abc/info.exe . If you want to run it like a Linux program, you need to install wine-binfmt . Then you can run it the same way as described above for Linux executables.
If you use Ubuntu, install wine like this:
sudo apt-get install wine wine-binfmt
How to Run Files in Linux
This article was co-authored by wikiHow staff writer, Travis Boylls. Travis Boylls is a Technology Writer and Editor for wikiHow. Travis has experience writing technology-related articles, providing software customer service, and in graphic design. He specializes in Windows, macOS, Android, iOS, and Linux platforms. He studied graphic design at Pikes Peak Community College.
This article has been viewed 83,017 times.
This wikiHow teaches you how to run files in Linux. You can run most files using a file manager program. Most Linux distributions have a default File Manager that comes pre-installed. You can also use the Terminal to run a file in Linux. This is the preferred method for running «.run», «.sh», and «.bin» files.
Using a File Manager
- If you are not sure where to locate your file browser app, you can press the Super (Windows) key and type «Files» (or the name of the file manager) in the search bar.
- If you don’t like the file manager that came with your Linux distribution, you can install a different file manager in the Terminal. To do so on Debian/Ubuntu, open the Terminal and type sudo apt install and press Enter. On Fedora, open the Terminal and type sudo dnf install and press Enter. Replace «» with the name of the app you want to install. [2] X Research source
Navigate to the folder the file is located in. Most file managers have a large panel that allows you to browse folders. Double-click a folder to open it. Navigate to the folder with the file you want to run.
- Alternatively, you can double-click the file to run it using the default application that the file type is associated with.
Click Open With or Open With Other Appllicaiton . This displays a list of applications you can use to run the file.
- If you don’t see the application you use to run the file, click View All Applications or Other. This displays a list of all installed apps categorized by type. Click the category of the app you want to run the file in. Then double-click the app you want to run the file in.
Using the Terminal
Press Ctrl + Alt + T to open the Terminal. You can open the Terminal by clicking the icon that resembles a black screen with a white text cursor in your Apps menu, or by press Ctrl+Alt+T on your keyboard.
- If asked to do so, enter the password you use to log into your Linux computer and press Enter.
- Run a file: sudo ./ . This includes «.sh», «.run», and «.bin» files.
- Open a file in it’s default application: xdg-open
- Display an image file: display . You must have ImageMagick installed. [3] X Research source
- Display a text file in the Terminal: cat .
- Display a text file one page at a time: less
- Display a text file with numbered lines: nl [4] X Research source
Expert Q&A
Tips
You Might Also Like
How to Use ChatGPT & OpenAI Without a Phone Number
6 Ways to Pair Your JBL Earbuds: Guide & Troubleshooting Tips
How to Turn on Backlit Keyboard on Lenovo
How to Use the Split Screen Feature on a Dell: Beginner’s Tutorial
Easy Ways to Read Crash Dump Files & Troubleshoot Crashes
What Does DW Mean? Snapchat, Texting, and More
How to Guess a Password
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?