28

I am new to Linux. I am currently trying to write a command line which should execute a *.exe inside a folder abc.

I have tried

% cd abc info.exe

But the error says no such file or directory.

Any suggestions?

30

try:

abc/info.exe

but if it's really a Windows program, you will need to install "wine", then do:

wine abc/info.exe

but only some Windows programs will work under wine.

10

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.

cd abc/
wine info.exe

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

cd abc/

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)

chmod a+x info.exe

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.

./info.exe
  • "you could try running it under a windows emulator (WINE)." WINE does stand for "Wine Is Not an Emulator"... – Mefitico Feb 18 '20 at 21:04
  • @Mefitico was that namesake meant to be ironic or informative? – Arctiic Feb 18 '20 at 23:32
  • 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. – Mefitico Feb 19 '20 at 16:08
8

you can't :) exe is Microsoft only. now if you had a linux executable you could do:

cd folder
chmod +x file
./file
  • 8
    This is false in general. Many Windows and DOS EXEs can be run on Linux using emulators such as wine or dosbox. – Susam Pal Nov 18 '13 at 11:11
  • 1
    Will a simple C / C++ Program (Using array math and 'printf()') compiled in VS 2017 work in DosBox? – Royi Feb 18 '18 at 12:57
  • @Royi probably "yes", but that depends on how simple we're talking. But wine should also do your trick. – Mefitico Feb 20 '20 at 13:28
6

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.

  • 1
    COuld you explain me. What you are trying to do as Im new – alice7 Sep 29 '09 at 22:24
  • 2
    The first line changes the directory, the second line tells linux it is executable, the third runs the program. – Byron Whitlock Sep 29 '09 at 22:35
3

I recently wanted to run some old MSDOS .exe files and I could just use dosbox. On Ubuntu it was just

apt-get install dosbox

then

dosbox file.exe

  • oh, it's a particular workaround, but is valid for msdos executables. – Francisco Tapia Jul 8 '15 at 18:24
2

.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.:

  1. cd abc; ./info.exe
  2. ./abc/info.exe
  3. /full/path/to/abc/info.exe
  4. 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 – user435225 Apr 7 '15 at 11:33
1

Wine is a program that you can install, which allows you to run .exe files on linux.

apt-get install wine

(go to the directory of your file: /cd (ex: Desktop/) And to open your .exe file:

wine PROGRAM [AGRUMENTS]

If you have any problems with wine, you can do wine --help.

0

Here is how to run an executable file in Linux:

  1. open terminal with ctrl + alt+ T: sudo apt-get update
  2. install Wine: sudo apt-get install wine
  3. go to the directory in which your .exe file is placed by changing directory: cd /Desktop
  4. wine filename.exe

Hit enter and your .exe file will be executed.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.