Linux command line exe

How to Run .Exe Executable File from Linux Command Line

How to run .exe executable file from linux command line?

Windows EXE files usually can’t run on Linux. You might be successful with wine which emulates MS Windows, though:

What do you mean by a runtime variable? A command line argument, or environment variable?

How to run .EXE with inputs on terminal in Unix/Linux?

If the program is just reading from stdin, you can simply do

printf '%s\n%s\n' 'someimage.tif' 'x y z coordinates' | ./Something.exe

Or if the shell you’re using is bash:

echo $'someimage.tif\nx y z coordinates' | ./Something.exe

How to run a .exe file with command prompt?

I need to run this file, take input from a text file and save output
in a text file.

Assuming you’re on Linux, this should work:

Run executable file from a different user

Your initial starting point both for installing the rpm and for running the service is privileged. For instance, on my CentOS 6 machine, I see in /etc/passwd

games:x:12:100:games:/usr/games:/sbin/nologin

but running as root, I can do this:

$ sudo -u games /bin/sh
sh-4.1$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
sh-4.1$ id
uid=12(games) gid=100(users) groups=100(users) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
sh-4.1$ cd
sh-4.1$ pwd
/usr/games

In your service script, you can use sudo to run a given process as another user (though a quick check of the same machine does not show this being done).

@msuchy points out that runuser may be preferable. I see that this is relatively recent (according to Ubuntu runuser command?, appeared in util-linux 2.23 — lacking a date makes release notes less than useful. ). The oblique comments in its documentation about PAM make it sound as if this circumvents some of the security checks. Perhaps someone has a better comment about that.

How to run executable file in Ubuntu as a command or service (with Node.js child_process.spawn())?

This is a path issue, node is unable to find service.linux file, use absolute path, issue will be resolved

run an .exe file in UNIX

If this executable came from the Windows environment, it won’t run under UNIX/Linux without lots of help.

  1. If you have the source code and the application doesn’t rely on a lot of Windows specific libraries, you could try compiling it in your current environment.
  2. The WINE emulator can often run Windows executables, depending again on what libraries from Windows are used.

If it isn’t a Windows exe and is native to your current environment, then ./exename.exe should work provided you have the permissions to execute it.

Читайте также:  Роса линукс общий доступ

How can I run a Windows executable from WSL (Ubuntu) Bash

Native solution

The official solution provided with Windows 10 Insider Preview Update (14951) is based on the almost forgotten binfmt_msc Linux facility for launching binaries. The registration command for the binfmt_misc would be like this (where /init is the provisional binfmt_misc «interpreter» for the win-executables):

sudo echo ":WSLInterop:M::MZ::/init:" > /proc/sys/fs/binfmt_misc/register

And then win-executable would be launched like regular programs:

$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir

Not that any win-executable must reside in the windows (DrvFs) file-system — not on the Linux’s file-system (VolFs) — in order to inherit a proper Windows working-directory.

The cbwin alternative

Untill you get the latest build, project cbwin offers a workaround, by installing 3 new linux commands inside WSL:

  • wcmd : call a win-executable through cmd.exe .
  • wrun : call a win-executable synchronously with CreateProcess , and wait to die (not using cmd.exe ).
  • wstart : launch a detached (asynchronously) command (with the use of cmd.exe ).

In order to use them, you must:

  • a new outbash.exe will be installed in your regular Windows filesystem (somewhere in your %PATH% ), plus
  • the 3 linux-commands in the WSL filesystem.

Tip: If the executable launched with wcmd or wrun spawns any children, these survive only for as long that executable remains alive.

In other words, trying to start notepad.exe with wcmd won’t work, because notepad will be killed just after having been launched — Use wrun (synchronously) or wstart (asynchronously) in this case.

Источник

How To Make A File Executable In Linux

If you’re someone with a background in a Windows operating system, chances are you’re aware of the “.exe” files. These files are referred to as executable files because their purpose is to execute a series of commands that make up the whole program.

However, when you make the change to a Linux distribution, this division of executable vs. non-executable does not apply. Any file can be made executable in Linux since it does not require a certain extension to be declared as an executable.

This provides a lot of flexibility when it comes to file management.

If you’re someone looking to learn how to make a file executable in Linux, then this guide is meant for you. We’ll provide a step-by-step solution on how you can make any file executable, either using the CLI or the GUI method.

Let’s take a look at the steps.

Method 1: Using The Command Terminal

The first method makes use of the Command Terminal. You can make any file executable by typing certain commands in the Terminal.

Although we’re going to be using Ubuntu 20.04 LTS in this guide, the steps shouldn’t be any different for other Linux distributions. With that said, just follow the steps explained with the help of an example.

First and foremost, open the Command Terminal on your system. The shortcut for Ubuntu is Ctrl + Alt + T.

For this guide, we’ll create a sample file using the echo command by using the following command:

Читайте также:  Linux время выполнения скрипта

This command will create a string literal with the text “This is a guide on how to make a file executable in Linux” and store it in a file called Test1.

To view the content of the file, type the following command:

You should notice that the file doesn’t end with an extension name. This means that you have the option to make the file executable.

In order to make Test1 an executable file, we’ll use the following command:

In case of a file extension, the command becomes:

Now you can call your file by typing its name in the Terminal as follow:

You can also execute the command in the following manner:

This will provide appropriate permission for the file to be executed.

If the CLI method seems complicated to you, worry not as you can achieve the same results with the help of the GUI.

Method 2: Using the GUI

Unlike the CLI method, the GUI method is much less daunting and simplified to understand what’s going on.

Follow these steps to make a file executable using the GUI.

Start by navigating to the file of your choice. Once you’ve navigated to the file, right-click on it and select “Properties”. A new window should appear.

Once a window opens, click on the Permissions tab.

In the Permissions tab, you should see an option titled “Allow executing file as program.”

You should now have the desired file in an executable format if you followed the steps correctly.

Understanding How File Execution Works

Learning how file execution works in Linux has its benefits as it provides more flexibility when it comes to an understanding of how the file works.

In Method 1, we used the command chmod +x. This was necessary in order to make the file executable since the file required “read” privileges. The “./” tells the Terminal to search for the location of the file.

Aside from Method 1, there are other ways to use the $ chmod command. This flexibility makes $ chmod extremely valuable. A list of options for the $ chmod command is given below:

  • $ chmod 775 . This mode allows anyone to execute the file. However, only the owner of the file has permission to write in that file.
  • $ chmod 0010 . Only users of a group will be allowed to execute the file.
  • $ chmod 0100 . Permission to execute the file belongs exclusively to the user.
  • $ chmod 777 . Provides permission to execute the file to all Linux users.
  • $ chmod -777 . Doesn’t allow any user to execute the file.

Additional Information

Although the $ chmod command works for files without extension type, it should be noted that you’ll need to specify the file type in case it’s mentioned. For example, if you are dealing with a file that has a .run or .bin extension. The syntax for the execution command would be:

Additionally, make sure you have the correct name, file type, and file location before making any file executable.

Conclusion

If you followed the steps in the guide correctly, then the good news is you are now aware of how to make a file executable in Linux.

Читайте также:  Установка linux сколько разделов

This guide covered different methods to make the file executable in Linux. We started by explaining the method involving the Command Terminal and followed up with the method to achieve the same with the help of the Graphical User Interface(GUI). We also covered additional uses of the $chmod command and the different permissions.

With this, we wish you all the best in your journey to master Linux.

Источник

How can I make a program executable from everywhere

What should I do if I want to be able to run a given program regardless of my current directory? Should I create a symbolic link to the program in the /bin folder?

I think it would be fine to create a personal ~/bin/ folder, add THAT to your path, and create symlinks in that folder to anything you wanted to be executable from anywhere.

I came across this which might help if you want to place an icon on your desktop to do it unixmen.com/create-a-launcher-in-ubuntu-using-bash

5 Answers 5

If you just type export PATH=$PATH: at the command line it will only last for the length of the session.

If you want to change it permanently add export PATH=$PATH: to your ~/.bashrc file (just at the end is fine).

Thanks it works. For newbies like me, remember to omit the angle brackets <>. Like so: $PATH:/your/file/path

also worth noting: for anyone using zshell as their default shell, edit ~/.zshrc with the PATH variable

Can someone explain how you can add export PATH=$PATH: to your ~/.bashrc file? What is exactly meant with this?

The short answer is that to run the program, no matter what your directory, you need to have the program’s directory in your search path. The problem can be solved by putting the program into a folder thats already in that path, or by adding a new folder to the path — either will work. The best answer depends on:

Is this program a downloaded program that you have compiled yourself from source?

Its quite likely will have an install mechanism already. In the folder that you compiled the program, as root, run ‘make install’

Is this program a downloaded program that you want to make available as part of the standard programs on the computer?

Makes sense to put this kind of application into a standard folder. its quite common to use directories such as /usr/local/bin for such programs. You will need root access to do this.

This is a program that you have written for yourself and/or you have no special privilages on the computer.

Creating a folder in your home directory called ‘bin’, and placing the program in there. You may need to edit your login script to add the full path to this folder (e.g. /usr/home/jeremy/bin)

Whilst you could just add its current directory to the search path, you will have to keep doing this with every new program — and is more work in the longer term.

Источник

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