How to run Windows programs on Linux. Running Windows programs under Linux

In essence, the operating system consists of a kernel and a huge set of programs that are designed to perform various tasks, maintain the system, and satisfy the needs of the user. Almost all interaction between the user and the operating system is done through programs. Therefore, it is important for beginners to understand how to run a program on Linux, what happens during startup, and what methods of launching it.

Before we move on to running programs, we must first understand what the program is. In Linux, programs differ from other files only in that they have an executable flag set. I already wrote about this in detail in the article, so I will not repeat myself.

All programs can be divided into several types:

  • Binary programs - contain instructions for the processor already ready for execution, most programs are in this format, they are fast and are executed immediately by the system;
  • Bytecode programs - these are no longer processor instructions, but instructions of a specific virtual machine that can execute them; without a virtual machine, such instructions cannot be executed. Such programs consume more resources, but are also fast enough, their advantage is that they can be executed without changing wherever a virtual machine can run. These programs include Java programs.
  • Scripting programs - These programs consist of a set of commands in plain text that are executed by a special interpreter. These programs are slower, but they are easier to develop and their code can be changed quickly and easily.

Now let's move on to launching programs.

Running programs in the terminal

Originally, the Unix and Linux operating systems did not have a graphical interface, so programs were run by commands from the terminal. Now it is also possible and quite actively used by experienced users. The syntax for starting the program looks like this:

/ path / to / file / program options

Parameters are only specified when needed, but the shell always needs to know the full path to the program. Everything after the program name and a space is parameters. You've probably already noticed that we usually do not specify the full path when executing programs. It would be very long and inconvenient.

The developers have come up with a workaround. The PATH variable was created, which stores all the paths to the folders where the programs are usually located - / bin, / sbin, / usr / bin, / usr / sbin and so on. You can view its contents with the command:

When you type the name of the program, the system searches for an executable file with this name in all folders from the PATH and if it finds it, it executes it. If there is no such file, then a message is displayed - command not found. Thus, to start one of the system programs, it is enough to type the name of its executable file, for example:

And you can pass parameters after the space:

When the program is not in these directories, you need to specify the full path to it:

/ usr / local / bin / ls1

If you want to run the program through the ubuntu terminal, which is located in the current folder, then the situation will be slightly different. The system searches only the folders from the PATH variable, it does not search in the current directory. Therefore, if you type the name of the executable file, you will get an error. You need to specify the full path, as you remember. /:

Sometimes it becomes necessary to transfer some special to the program. For example, the EDITOR variable indicates which text editor to use by default. You can specify the variable name and value before the command name using the syntax:

variable_name \u003d value command

For instance:

EDITOR \u003d nano visudo

By default, this command opens the settings in the Vim editor, but with this environment variable, the settings will open in the nano editor.

Run programs as another user

You already know how to run the program in the linux terminal, but what about other users? In Windows, it is often used to run programs as an administrator so that the program can gain more access rights in the system. On Linux, the sudo utility is used for this. Her name can be decoded as switch user do - change user and execute. By default, the utility runs the command as the root superuser:

sudo command
sudo whoami

But using the -u option, you can run the program as any user logged on to the system:

sudo -u username command
sudo -u postgres whoami

The whoami command displays the name of the current user.

How to run a program in the background

Sometimes it becomes necessary to run a long-running program in the terminal so that it does not interfere with further work. To do this, you can use the program launch in the background linux:

program_name &

For instance:

dd if \u003d / dev / zero of \u003d ~ / file count \u003d 100000 &

The system will print the PID, a unique identifier for the program, which you can then use to close it:

How to run a script on Linux

We have already said that programs are divided into binary and interpreted. Earlier we only talked about binary programs. To run interpreted ones, you need an interpreter directly, such programs include those written in languages \u200b\u200bsuch as Java, Python, Perl, Ruby, PHP, NodeJS and many others. The syntax for launching such a program is different:

interpreter / path / to / file / program options

Different interpreters behave differently, so it's better to specify the full path to the program right away. Python usually picks up scripts from the current folder without specifying the full path:

python hellowrld.py

And Java programs need to be run like this:

java -jar program.jar

For files of interpreted programs, the executable flag is optional, since they are passed as a parameter to the main program. Only Bash scripts are an exception. You can run the script with the interpreter:

Or just type the path to the script:

The shell identifies its scripts by the executable flag and executes them. If the executable flag is not set, then it should be added:

sudo chmod u + x ./script.sh

Therefore, for most of the interpreted programs, simple sh scripts are created with which you can quickly run them.

Running Linux programs in a graphical interface

It is much more convenient to run programs through a graphical interface. If it is impossible to run console programs like this, then there are shortcuts for all graphical utilities, which you can find in the main menu of the system:

In addition, you can run the program from the file manager by double-clicking, but then the executable flag must be set for it.

Running scripts in a graphical interface works the same way. You can find all the shortcuts from the menu in the / usr / share / applications / directory. Any program can be launched by double clicking from here. But let's see what's inside the shortcut, to do this, open it in a text editor:


Among other things, the Exec line contains a command that launches a linux program when you double-click on a shortcut. You can take one of the existing shortcuts and make your own based on it. This is just the name of the program. But it is important to note that it is better to specify the full path in places such as shortcuts, scripts, cron, and so on, this will reduce the number of errors, since you cannot know if the system checks the PATH in this case or looks for the program only in the current directory. Now you know everything about how to run a program on linux.

conclusions

In this article, we looked at how to run the program through the ubuntu terminal or other Linux distributions. While this seems like a very simple topic, there are some interesting points that can be useful. But you already know about them. If you have any questions, ask in the comments!

Many users are afraid of switching to Linux due to various rumors about its complexity, glitchiness or unavailability for desktops. You can get acquainted with the appearance of linux and its functionality, check for familiar programs (web browser, mailer, audio and video player, office suites ...) without installing Linux on your computer.

These tips are also suitable for those who are already familiar with Linux, but want to try a different distribution or play with a new program without installing it on the main system.

Linux friends and acquaintances

The easiest and most obvious way to get acquainted with Linux. If you have familiar Linux users, ask them to show you this operating system and explain what's what. And in general, the first time using Linux is very useful to have a person at hand who can answer your questions. And given the adherence of the bulk of Linux users to open source software and hatred of windows / apple, the likelihood of being rejected is extremely small.

LiveCD or LiveUSB

Another way to look at the capabilities of Linux is to write a livecd image to disk or liveusb to a flash drive and boot from it. At the moment there are many distributions that can work without installation on a computer (from a bootable flash drive or livecd). All popular distributions (gentoo, ubuntu, debian ...) are available as a bootable flash drive or as a livecd image.

In addition, there are tons of livecd-only distributions. Most of them are based on the package base of popular distributions (gentoo, debian, redhat ...). Some of them are built for a specific purpose, for example, for system recovery (such distributions include utilities for working with file systems and other useful things). There are even bootable livecds for gamers with a selection of different games.

It is worth noting that on computers with a small amount of RAM, livecd and liveusb distributions run slowly. In such cases, you can speed up the work a little by choosing a light DE (desktop environment) at boot: openbox, lxde, xfce4; or abandoning graphics altogether and loading only in text mode.

For a complete list of live distributions, visit distrowatch.com.

Wubi (ubuntu on windows)

Wubi (Windows-based Ubuntu Installer) is the official free Ubuntu Linux installer designed to run on Windows operating systems, licensed under the GPL. With Wubi, Windows users can install and uninstall Ubuntu just like a regular Windows program. ()

Virtual machine

The option with a virtual machine is very convenient. It allows you to run multiple operating systems without even restarting your computer.

The most famous are the following virtual machines: VirtualBox, VMware Player, Virtual PC

For instructions on starting the operating system inside a virtual machine, see the documentation on the official sites.

Remote access to a Linux machine

You can try to get an account on some linux machine with the ability to connect via ssh. Ask friends, an admin at work, a computer science teacher at a school / institute, or look for freebies. Many Internet Service Providers (ISPs) allocate some space on the server for their home page to their network users on request and provide ssh access.

To connect to a remote linux-machine via ssh from windows, I can recommend the putty program.

There is another option with the purchase of a server / vds / shared-hosting with the ability to access via ssh. But this is for the case when you want not just to look, but to do something more serious.

Cygwin

If you are a Windows user and do not need a graphical linux environment, you can use the Cygwin emulator. If X is still needed, you can try to install the X Window System port on Windows - Cygwin / X (I myself have not tried it and therefore cannot say anything specific).

Cygwin is not linux or unix. It is a tool for porting UNIX software to Windows and is implemented as a library that implements the POSIX API based on Win32 system calls. Cygwin also includes the GNU development tools for basic programming tasks, as well as some application programs equivalent to the UNIX base programs.

In simple language: to run shell scripts and write programs (there is gcc) it is quite enough.

Is it possible to run Linux from under Windows?

The issue is resolved and closed.

The best answer

Answers

      2 0

    2 (494) 2 11 4 g

    In general, I gave you a couple of useful links, read, delve into.
    http://www.pcwork.ru/kak_zapuskat_linux_pod_windows.html
    http://rus-linux.net/MyLDP/win-lin/dostup-k-linux-iz-windows.html

      1 1

    7 (92213) 34 176 787 4 g

    How to run Linux on Windows

    How to Run Linux on Windows Linux is known for its stability, protection against spyware and viruses, and as a symbol of inexpensive computer software. If you think you need to buy a new computer to install and run Linux, then there is good news for you. You can run Linux on an existing computer in parallel with Windows.

    Even better, there are three options for running Linux on a Windows computer, depending on the user's needs and technical skills.

    Option 1: Use a virtualization or emulation program that lets you run Linux in a separate window on the Windows desktop.

    Running Linux in a Windows virtual machine

    There are several programs that allow you to run Linux in a "virtual machine" on the Windows desktop. The two most popular emulation programs are Parallels Workstation ($ 49 after a 15-day free trial) and VMWare Workstation ($ 189 after a 30-day free trial). If your computer is already running Windows XP and you want to install Linux, Parallels or VMWare can help you install Linux as a "guest" operating system in the virtual machine created by the program.

    In any case, the installation of the emulation programs is user-friendly and takes only a few minutes. After installation, you need to follow the prompts to set up a Linux virtual machine and then install a version of Linux that is either downloaded from the Internet or stored on a CD. Both Parallels and VMWare support the most popular Linux versions: Ubuntu, Red Hat, and SuSE.

    Running Linux in a separate window on the Windows desktop allows you to compare two operating systems, you can even exchange files between them, or copy text on one system and paste into the other.

    Running Linux and Windows with Dual Boot

    It is possible to create a dual boot, in which, during computer startup, you can choose which operating system will be loaded. If you want the best performance from a Linux system, it should work in its inherent mode, that is, directly with the hardware of the computer, and not in a virtual machine.

    To partition a hard disk to be able to perform a dual boot, you can use programs such as Acronis Disk Director, Norton Commander, or use the disk partitioning utility included with the Linux distribution. Typically, the Linux installer will help you partition your hard disk into two or more partitions, with the installed Windows on one partition and the other on Linux. An operating system boot loader such as LILO or GRUB is also installed to help you select the correct operating system when you turn on your computer.

    It should be remembered that dual boot DOES NOT ALLOW the simultaneous operation of two operating systems, unlike the previously mentioned emulation programs. In this case, to move from one system to another, one should boot one system, shut it down and then boot the other system.

    The bootable Live CD option allows you to insert a CD containing the complete Linux system into the drive of your Windows computer and boot Linux from that CD. This is probably the easiest way for a new Linux user to try out the operating system on a Windows computer. The disadvantage of booting from a Live CD is that it makes the operating system much slower than booting from a hard drive. However, this option allows you to sample a GUI user interface, launch a web browser, play some Linux games, and work in office applications.

    There are several companies that make bootable Live CDs including Ubuntu, PCLinuxOS, Knoppix and (excuse me French) Damn Small Linux. In any case, you need to download a huge file from the Internet, which is an "image" of the Linux installation disk. This image is then written to a CDROM and used to boot the system. Damn Small Linux (bare-bones Linux) is only 50 MB in size (compared to approximately 700 MB for other versions) and can be booted from either a CD or an image on the Windows desktop. However, if you want to experience a prettier graphical version of Linux, your best bet is Ubuntu.

    Choose the option that best suits your needs and give Linux a try. Windows installed on your computer will be waiting for your return. Unless, of course, you decide to switch to Linux forever.

The use of Linux- or UNIX-applications in Windows can be dictated by a variety of reasons - from a banal habit of some programs to the impossibility of starting a separate Linux machine. Someone wants to use native versions of software for debugging, and someone hopes that in this way it is possible to force users to smoothly migrate to a full-fledged distribution.

Before making a fuss with emulators, it is better to look for ported versions or analogues of your favorite programs. The same GIMP, Audacity, Pidgin and many other utilities have native assemblies not only for Windows, but also for Mac OS X. To obtain any specific functionality, a full-fledged analogue of Linux software is often not required. For example, you get used to Tab autocompletion in bash very quickly, but there is no trace of it in the Windows command line. The clink utility will help fix this and other annoying omissions.

Standard console utilities, for example from the GNU Coreutils package, have long been ported to Windows. There are both fairly old sets of GNUWin II and, and constantly updated UWIN (not recommended for use) and. For the latter, after completing the installation of the basic installer, you need to run the download.bat and install.bat files sequentially, and then copy the gnuwin32 folder to any convenient location and run the update-links.bat file from it. After running the last script in the StartMenu subdirectory there will be links to starting the command line with the GNU environment and the documentation for the utilities.


Owners of Windows Vista / 7 in maximum and corporate versions, as well as server versions of Microsoft OS may not bother at all. For them, a subsystem for UNIX-based applications (Subsystem for UNIX-based Applications, SUA) or Microsoft Windows Services for UNIX (Microsoft Windows Services for UNIX, SFU) are available. This set of basic utilities is present right in the system components. Additional software kits can be downloaded. Finally, the last on the list and the first most popular solution for running UNIX programs is Cygwin. This package is easy to install and contains far from a small set of applications ported to Windows. It is recommended to use it.




Now we can talk about the strange - starting a non-Windows system KDE. In fact, the KDE on Windows project has existed for several years, and at first it was simply impossible to use it due to regular crashes, which perhaps did not drive the unfortunate system into BSOD. However, the developers did not sit idly by, and in the current reincarnation of the project it can be safely installed - errors are quite rare, and even those are not critical. It probably doesn't make sense to put everything at once, but some applications may appeal to you.





Unfortunately, ported applications do not always behave as they do in their native environment, or they may conflict with other programs. Therefore, the only way out, apart from installing a "penguin" OS on bare metal, is to emulate Linux. For one-time use, you can use a shell for QEMU called MobaLiveCD, which, without unnecessary gestures, will help you run LiveCD / USB with various distributions. For permanent use, it is better to install Linux in a virtual machine: in VirtualBox or VMWare Player. Just don't forget to install Guest Additions for a more comfortable experience. An alternative option is the use of VDI solutions with the ability to seamlessly integrate into Windows Linux applications running on a separate host, which can also be virtualized.


The best option for running Linux applications is to use the coLinux environment. It, relatively speaking, runs the Linux kernel at the Windows kernel level and has access to all the hardware resources of the machine, due to which there is practically no performance loss. At the same time, it maintains full compatibility with Linux-applications, allowing them to run directly. On the basis of coLinux there are ready-made systems for quick start, Topologilinux (Slackware) (various distributions) and andLinux (Ubuntu). The only unpleasant limitation of coLinux and all packages based on it is the need to use the 32-bit version of Windows 2k / XP / 2k3 / Vista / 7. Let's take a look at the minimal Debian Squeeze setup as an example. The first step is to install the latest version, refusing to download ready-made images and installing WinPcap along the way.


Now you need to archive the Debian disk image and unpack it into the folder where coLinux was installed. The rootfs_2gb.img disk size can be increased if desired. The squeeze.conf file will need to be edited a bit. Minimum changes - increase the amount of allocated RAM (mem), allow access to the C: drive via COFS and add the TAP network interface. Note that when using COFS it is best not to access the same folder files from Linux and Windows at the same time.

Kernel \u003d vmlinux cobd0 \u003d "rootfs_2gb.img" cobd1 \u003d "swap_128mb.img" root \u003d / dev / cobd0 ro cofs0 \u003d "C: \\" initrd \u003d initrd.gz mem \u003d 512 eth0 \u003d slirp eth1 \u003d tuntap

After launching squeeze.bat, you will be taken to the Debian console. The default login is root and there is no password. Using nano, edit the network interface parameters in the / etc / network / interfaces file. Let's add a section for eth1. We use any IP-address, as long as there is no intersection with other local subnets. In Windows, in the IPv4 settings of the TAP-Win32 Adapter V8 (coLinux) network adapter, you must specify an address from the same subnet.

Auto eth1 iface eth1 inet static address 192.168.100.2 netmask 255.255.255.0

We exit nano with saving changes - F2, Y, Enter. Now let's create a folder where the C: drive will be mounted ...

Mkdir / mnt / windrvc

... add one line to the end of the / etc / fstab file and save it:

/ dev / cofs0 / mnt / windrvc cofs defaults 0 0

Now we are going to install the X-server, but for now, for simplicity, we will register the export of the DISPLAY variable to the ~ / .profile file (this will have to be done for any other users). Use the one specified for the TAP adapter in Windows as the IP address. After that, you can reboot with the reboot command.

Export DISPLAY \u003d 192.168.100.1: 0

It would be useful to install a set, including Cyrillic ones. Optionally, you can browse through the font directories, including C: \\ Windows \\ Fonts, the mkfontdir and mkfontscale utilities from Cygwin. You are now ready to install the X server. Immediately after this procedure, add the IP address of the TAP interface in Debian to the X0.hosts file (in our example, it is 192.168.100.2).


"Thank you" Windows for being vigilant and in the standard firewall we will change all the rules concerning Xming from forbidding to allowing, otherwise the programs will simply not reach the X-server. Now we launch the XLaunch utility, in which you can select the display mode for X-windows and set additional parameters. It is important for us to configure support for Russian and English layouts with Alt + Shift switching and optionally set DPI. At the end, the settings file should be saved as name.xlaunch. In the future, by double-clicking on this file, the X-server will be launched with the parameters we specified.

Xkblayout us, ru -xkbvariant basic, winkeys -xkboptions grp: alt_shift_toggle -dpi 96


In order not to be so boring, we will install the synaptic graphical package manager for a more convenient software installation and some lightweight panel with an application menu, for example lxpanel. For the sake of simplicity, we will prescribe the latter to autorun at login by adding the lxpanel & command to the end of ~ / .profile.

Apt-get update apt-get upgrade apt-get install synaptic lxpanel

For completeness, let's add audio support. Download the Pulseadio archive from here and unpack it into some directory in which we create the default.pa text file. We fill this file with the following lines. Here 192.168.100.0/24 is our TAP subnet.

Load-module module-native-protocol-tcp auth-ip-acl \u003d 127.0.0.1; 192.168.100.0/24 load-module module-esound-protocol-tcp auth-ip-acl \u003d 127.0.0.1; 192.168.100.0/24 load-module module-detect add-autoload-sink output module-waveout sink_name \u003d output set-default-sink output

Launch pulseaudio.exe and once again go to edit the permissions in the Windows firewall. Install the necessary utilities and libraries in the Debian console.

Apt-get install libpulse0 libasound2-plugins alsa-utils

In the /etc/pulse/client.conf file, add the IP address of the host machine running the Pulseaudio server - default-server \u003d 192.168.100.1, and in /etc/asound.conf the following parameters:

Pcm.! Default (type pulse) ctl.! Default (type pulse) pcm.pulse (type pulse) ctl.pulse (type pulse)


To test the functionality, you can try to play one of the test files.

Aplay /usr/share/sounds/alsa/Front_Center.wav

Pulseaudio starts automatically when Debian starts up by adding this command to the end of the squeeze.conf configuration file.

Exec0 \u003d "X: \\ path \\ to \\ folder \\ pulseaudio \\ pulseaudio.exe"

This trick is not suitable for an X server. In principle, what has already been done is enough for the job. However, it would be nice to add a new non-root user to Linux, set up autoloading with mingetty for it, install coLinux as a Windows service, and set Xming to autorun. For convenience, you can install the Desktops utility, which creates multiple virtual desktops in Windows, and run the X server in full screen mode on the second desktop.

As a result, we got a fast environment for almost native launch of Linux applications on Windows. It can be used to write and debug web applications, cross-compile drivers and other tasks. But there is still no sane graphics acceleration for heavy applications, and the 64-bit version began to be developed only a few months ago. However, coLinux is fine for everyday use. To further explore the capabilities and settings of this system, refer to the project wiki. Well, with this, for now, we will close the topic of the symbiotic relationship between Windows and Linux through different places. Good luck!

Did you like the article? To share with friends: