Run linux file on windows

Running Linux programs on Windows

To run a Linux program on Windows, you have these options:

  • Run the program as-is on the Windows Subsystem for Linux (WSL). In WSL your program executes directly on the machine hardware, not in a virtual machine. WSL also enables direct filesystem calls between Windows and Linux systems, removing the need for SSL transport. WSL is designed as a command-line environment and is not recommended for graphics-intensive applications. For more information, see Windows Subsystem for Linux Documentation.
  • Run the program as-is in a Linux virtual machine or Docker container, either on your local machine or on Azure. For more information, see Virtual Machines and Docker on Azure.
  • Compile the program using gcc or clang in the MinGW or MinGW-w64 environments, which provide a translation layer from Linux to Windows system calls.
  • Compile and run the program using gcc or clang in the Cygwin environment, which provides a more complete Linux environment on Windows compared to MinGW or MinGW-w64.
  • Manually port your code from Linux and compile for Windows using Microsoft C++ (MSVC). This involves refactoring platform-independent code into separate libraries, and then re-writing the Linux-specific code to use Windows-specific code (for example, Win32 or DirectX APIs). For applications that require high performance graphics, this is probably the best option.

Feedback

Submit and view feedback for

Источник

Run Linux GUI apps on the Windows Subsystem for Linux

Windows Subsystem for Linux (WSL) now supports running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience.

WSL 2 enables Linux GUI applications to feel native and natural to use on Windows.

  • Launch Linux apps from the Windows Start menu
  • Pin Linux apps to the Windows task bar
  • Use alt-tab to switch between Linux and Windows apps
  • Cut + Paste across Windows and Linux apps

You can now integrate both Windows and Linux applications into your workflow for a seamless desktop experience.

Screenshot of Linux and Windows apps open on a desktop

Install support for Linux GUI apps

Prerequisites

  • You will need to be on Windows 10 Build 19044+ or Windows 11 to access this feature.
  • Installed driver for vGPU To run Linux GUI apps, you should first install the driver matching your system below. This will enable you to use a virtual GPU (vGPU) so you can benefit from hardware accelerated OpenGL rendering.
    • Intel GPU driver
    • AMD GPU driver
    • NVIDIA GPU driver

    Fresh install — No prior WSL installation

    You can now install everything you need to run Windows Subsystem for Linux (WSL) by entering this command in an administrator PowerShell or Windows Command Prompt and then restarting your machine.

    Once your machine has finished rebooting, installation will continue and you will be asked to enter a username and password. This will be your Linux credential for the Ubuntu distribution.

    You’re now ready to begin using Linux GUI apps on WSL!

    Existing WSL install

    If you already have WSL installed on your machine, you can update to the latest version that includes Linux GUI support by running the update command from an elevated command prompt.

    1. Select Start, type PowerShell, right-click Windows PowerShell, and then select Run as administrator.
    2. Enter the WSL update command:

    Linux GUI apps are only supported with WSL 2 and will not work with a Linux distribution configured for WSL 1. Read about how to change your distribution from WSL 1 to WSL 2.

    Run Linux GUI apps

    You can run the following commands from your Linux terminal to download and install these popular Linux applications. If you are using a different distribution than Ubuntu, it may use a different package manager than apt. Once the Linux application is installed, you can find it in your Start menu under the distribution name. For example: Ubuntu -> Microsoft Edge .

    Support for GUI apps on WSL does not provide a full desktop experience. It relies on Windows desktop, so installing desktop-focused tools or apps may not be supported. To request additional support, you can file an issue in the WSLg repo on GitHub.

    Update the packages in your distribution

    Install Gnome Text Editor

    Gnome Text Editor is the default text editor of the GNOME desktop environment.

    sudo apt install gnome-text-editor -y 

    To launch your bashrc file in the editor, enter: gnome-text-editor ~/.bashrc

    Install GIMP

    GIMP is a free and open-source raster graphics editor used for image manipulation and image editing, free-form drawing, transcoding between different image file formats, and more specialized tasks.

    Install Nautilus

    Nautilus, also known as GNOME Files, is the file manager for the GNOME desktop. (Similar to Windows File Explorer).

    sudo apt install nautilus -y 

    Install VLC

    VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files.

    Install X11 apps

    X11 is the Linux windowing system and this is a miscellaneous collection of apps and tools that ship with it, such as the xclock, xcalc calculator, xclipboard for cut and paste, xev for event testing, etc. See the x.org docs for more info.

    sudo apt install x11-apps -y 

    To launch, enter the name of the tool you would like to use. For example:

    Install Google Chrome for Linux

    To install the Google Chrome for Linux:

    1. Change directories into the temp folder: cd /tmp
    2. Use wget to download it: sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    3. Get the current stable version: sudo dpkg -i google-chrome-stable_current_amd64.deb
    4. Fix the package: sudo apt install —fix-broken -y
    5. Configure the package: sudo dpkg -i google-chrome-stable_current_amd64.deb

    To launch, enter: google-chrome

    Install Microsoft Edge browser for Linux

    Find information on how to install the Microsoft Edge browser for Linux using the command line on the Edge Insider site. Select Get instructions under the Command line installation section of the page.

    To launch, enter: microsoft-edge

    Troubleshooting

    If you have any problem starting GUI applications please check this guide first: Diagnosing «cannot open display» type issues with WSLg

    Feedback

    Submit and view feedback for

    Источник

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Под GNU/Linux-дистрибутивы создано огромное количество полезных и удобных инструментов и приложений для обычных пользователей и разработчиков. Далеко не всё из этого доступно на Windows, но, к счастью, для ОС от Microsoft есть решения, исправляющие эту проблему.

    WSL — официальная подсистема Linux внутри Windows

    В Windows 10 существует крайне полезная вещь под названием Windows Subsystem for Linux (WSL). Она позволяет использовать GNU/Linux-среду прямо в Windows и запускать не только команды, но и, например, Bash-скрипты. Для использования WSL необходимо следовать инструкции ниже.

    Шаг 1. Проверьте, подходит ли текущая версия Windows требованиям. Для этого нажмите сочетание клавиш Win+R, затем введите winver. Найдите строку «Сборка ОС» — она должна быть свежее версии 14316.

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Шаг 2. Запустите стандартную утилиту PowerShell от имени администратора и введите в ней команду для включения WSL:

    Шаг 3. Если версия Windows, определённая в первом пункте, свежее 18362, вы можете установить WSL 2, который в разы быстрее первой версии и обладает доработанным ядром. Введите команду ниже, если нужно установить WSL 2:

    После этого скачайте и установите пакет обновления с официального сайта.

    Шаг 4. Перезагрузите компьютер. Если была произведена установка WSL 2, введите в PowerShell от имени администратора следующую команду:

    Шаг 5. После перезагрузки откройте фирменный магазин приложений Microsoft Store и найдите подходящий GNU/Linux-дистрибутив. Самым популярным является Ubuntu — вы можете установить любую версию из представленных в Microsoft Store.

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Шаг 6. Как только установка завершится, найдите дистрибутив в меню «Пуск» и запустите его.

    Шаг 7. Пройдите этап первоначальной настройки, введя имя нового пользователя и придумав пароль.

    Шаг 8. Теперь различные GNU/Linux-команды можно выполнять, запустив дистрибутив, либо введя в командной строке wsl . Например, для просмотра всех файлов в текущей директории достаточно в командной строке выполнить wsl ls -a.

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Обращу внимание на то, что путь к дискам в WSL отличается от такового в Windows. Вместо привычного C:/ используйте /mnt/c/. Также не забывайте про экранирование пробелов с помощью символа \ — это также пригодится при вводе путей к файлам.

    Помимо выполнения базовых команд, с помощью WSL можно даже запускать приложения с графическим интерфейсом. Правда, рассчитывать на большое количество поддерживаемых подобных программ не стоит.

    Шаг 1. Загрузите X-сервер и установите его.

    Шаг 2. Запустите его с помощью ярлыка на рабочем столе. В открывшемся окне выберите вариант Multiple windows, затем Start no client. Завершите настройку кнопкой Finish.

    Шаг 3. Откройте дистрибутив через меню Пуск и выполните команду export DISPLAY=:0

    Шаг 4. Запустив приложение с графическим интерфейсом в WSL, вы увидите новое окно прямо в Windows.

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    CoreUtils — лёгкий инструмент для запуска базовых команд

    Плюс данной утилиты — возможность запуска не только на Windows 10, но и на более старых версиях ОС. Кроме того, она легка и не занимает много места. Не обошлось без недостатков — программа скудна на функционал и не обновлялась очень давно. Она не только не умеет запускать скрипты и приложения с GUI, но и поддерживает лишь самые базовые GNU/Linux-команды. Установка CoreUtils весьма проста.

    Шаг 1. Скачайте утилиту с официального сайта.

    Шаг 2. Следуйте инструкциям установщика.

    Шаг 3. Откройте «Панель управления», в разделе «Система и безопасность» выберите пункт «Система». На панели слева откройте «Дополнительные параметры системы». Нажмите кнопку «Переменные среды» и в открывшемся окне найдите область с заголовком «Системные переменные». В случае, когда там есть переменная Path, выберите её, нажмите «Изменить» и далее создайте новую строку. Содержимым этой строки должен быть путь к папке, который был указан при установке. Если вы ничего не меняли, то введите следующее:

    Переменной Path нет? Тогда для начала создайте её кнопкой «Создать», затем в поле имени введите Path, а в поле значения — строку выше.

    Шаг 4. Запустите командную строку и выполняйте команды прямо там.

    Cygwin — запуск команд и Bash-скриптов

    Ещё одна утилита, схожая с CoreUtils, но обладающая более широким функционалом — в том числе и возможностью запуска скриптов. Из минусов — немалый вес и более сложная установка. Разумеется, не идёт ни в какое сравнение с максимально удобным WSL, но для базовых команд вполне подойдёт.

    Шаг 1. Загрузите Cygwin и запустите установку.

    Шаг 2. Выберите Install from Internet, укажите директории для установки и загрузки пакетов, а также любой подходящий сайт из списка для скачивания файлов.

    Шаг 3. В процессе установки можете выбрать необходимые пакеты, либо сразу нажать «Далее», оставив базовый набор.

    Шаг 4. Откройте «Панель управления», в разделе «Система и безопасность» выберите пункт «Система». На панели слева откройте «Дополнительные параметры системы». Нажмите кнопку «Переменные среды» и в открывшемся окне найдите область с заголовком «Системные переменные». В случае, когда там есть переменная Path, выберите её, нажмите «Изменить» и далее создайте новую строку. Содержимым этой строки должен быть путь к папке, который был указан при установке. Если вы ничего не меняли, то введите следующее:

    Переменной Path нет? Тогда для начала создайте её кнопкой «Создать», затем в поле имени введите Path, а в поле значения — строку выше.

    Как выполнять Linux-команды внутри Windows: официальный и сторонние способы Как выполнять Linux-команды внутри Windows: официальный и сторонние способы

    Шаг 5. Команды можно выполнять как через командную строку, так и через специальный терминал.

    Шаг 6. Для удаления Cygwin достаточно удалить папку, в которую программа была установлена, а также (по желанию) значение из переменной Path по методу, обратному тому, что был описан в 4 шаге (не удаляйте саму переменную).

    Источник

    Читайте также:  How to create zip linux
Оцените статью
Adblock
detector