Running linux on windows computer

4 Ways to Run Linux Commands in Windows

Last updated October 29, 2020 By Abhishek Prakash 16 Comments

Brief: Want to use Linux commands but don’t want to leave Windows? Here are several ways to run Linux bash commands in Windows.

If you are learning Shell scripting probably as a part of your course curriculum, you need to use Linux commands to practice the commands and scripting.

Your school lab might have Linux installed but personally you don’t have a Linux laptop but the regular Windows computer like everyone else. Your homework needs to run Linux commands and you wonder how to run Bash commands and scripts on Windows.

You can install Linux alongside Windows in dual boot mode. This method allows you to choose either Linux or Windows when you start your computer. But taking all the trouble to mess with partitions for the sole purpose of running Linux command may not be for everyone.

You can also use Linux terminals online but your work won’t be saved here.

The good news is that there are several ways you can run Linux commands inside Windows, like any regular application. Isn’t it cool?

Using Linux commands inside Windows

As an ardent Linux user and promoter, I would like to see more and more people using ‘real’ Linux but I understand that at times, that’s not the priority. If you are just looking to practice Linux to pass your exams, you can use one of these methods for running Bash commands on Windows.

1. Use Linux Bash Shell on Windows 10

Did you know that you can run a Linux distribution inside Windows 10? The Windows Subsystem for Linux (WSL) allows you to run Linux inside Windows. The upcoming version of WSL will be using the real Linux kernel inside Windows.

This WSL, also called Bash on Windows, gives you a Linux distribution in command line mode running as a regular Windows application. Don’t be scared with the command line mode because your purpose is to run Linux commands. That’s all you need.

You can find some popular Linux distributions like Ubuntu, Kali Linux, openSUSE etc in Windows Store. You just have to download and install it like any other Windows application. Once installed, you can run all the Linux commands you want.

Linux distributions in Windows 10 Store

2. Use Git Bash to run Bash commands on Windows

You probably know what Git is. It’s a version control system developed by Linux creator Linus Torvalds.

Git for Windows is a set of tools that allows you to use Git in both command line and graphical interfaces. One of the tools included in Git for Windows is Git Bash.

Git Bash application provides and emulation layer for Git command line. Apart from Git commands, Git Bash also supports many Bash utilities such as ssh, scp, cat, find etc.

In other words, you can run many common Linux/Bash commands using the Git Bash application.

You can install Git Bash in Windows by downloading and installing the Git for Windows tool for free from its website.

3. Using Linux commands in Windows with Cygwin

If you want to run Linux commands in Windows, Cygwin is a recommended tool. Cygwin was created in 1995 to provide a POSIX-compatible environment that runs natively on Windows. Cygwin is a free and open source software maintained by Red Hat employees and many other volunteers.

For two decades, Windows users use Cygwin for running and practicing Linux/Bash commands. Even I used Cygwin to learn Linux commands more than a decade ago.

You can download Cygwin from its official website below. I also advise you to refer to this Cygwin cheat sheet to get started with it.

Читайте также:  Mac os 32 bit для virtualbox

4. Use Linux in virtual machine

Another way is to use a virtualization software and install Linux in it. This way, you install a Linux distribution (with graphical interface) inside Windows and run it like a regular Windows application.

This method requires that your system has a good amount of RAM, at least 4 GB but better if you have over 8 GB of RAM. The good thing here is that you get the real feel of using a desktop Linux. If you like the interface, you may later decide to switch to Linux completely.

There are two popular tools for creating virtual machines on Windows, Oracle VirtualBox and VMware Workstation Player. You can use either of the two. Personally, I prefer VirtualBox.

Conclusion

The best way to run Linux commands is to use Linux. When installing Linux is not an option, these tools allow you to run Linux commands on Windows. Give them a try and see which method is best suited for you.

Like what you read? Please share it with others.

How to Run Linux on Windows 10

Linux users celebrated when it was reported that Bash shell was coming to Windows. And while it was not readily available to all users at first, the Windows 10 Creators Update made Linux on Windows more accessible.

Want to join in on the fun? Here’s how you can have Linux on Windows operating system without having to go through a virtual machine.

Defining Bash

Bash is basically a subsystem for Ubuntu. With Bash, you have a Linux system running inside Windows. It’s the very same Bash you’d find in Linux. You can use it to execute Linux commands without the need for a virtual machine or dual booting.

Using Bash shell, developers can experience Linux natively on a Windows machine.

Enabling Linux on Windows

There are two ways of enabling a Windows subsystem for Linux. One is through PowerShell and the other would be through Windows Features.

Use PowerShell

Search for PowerShell and run it as an administrator. Once open, type this command and press Enter after:

You will be prompted to confirm by hitting Y or N. Press Y to proceed then reboot your computer. If it’s already installed, you won’t have to restart.

Use Windows Features

Use Search to look for a Control Panel application called Turn Windows Features On or Off.

Note: You can also get to the application by heading directly to Control Panel > Programs > Programs and Features > Turn Windows Features On or Off.

Once open, go through the list of features until you find Windows Subsystem for Linux. Tick the box to enable the option.

The computer will run and apply some changes. After it’s done, you will be asked to restart your computer.

Downloading a Linux Distro

Windows should now be able to run Linux. Now you have to download a Linux distro like Ubuntu for Windows to enter Linux commands.

Simply head on over to the Microsoft Store and download the Linux distro of your choice. You need to be logged in to proceed.

There are multiple systems available, but we’ll install Ubuntu and use it throughout the rest of this post. The download will likely take a while because of the large file size.

Running Linux

The Linux system you installed will run like a regular Windows application. Open Ubuntu. It will perform a one-time installation. You will be able to use Ubuntu Linux faster the next time you open the application.

Once installed, you will be asked to enter a username and a password. Provide all the necessary information.

From here on out, you will be able to go through the directory as you would in Linux. You will need to use SUDO APT to run root commands. You can also use APT-GET, APT INSTALL, AND APT UPDATE. You’re pretty much free to do everything you can do in a Linux terminal.

One thing to remember is that the Windows files system will be located inside the MNT folder.

If you want to edit Windows files from the Linux system, you would have to enter CD MNT, do LS then enter CD C and another LS to locate all the files stored inside Windows. Enjoy Linux with Windows 10!

Christopher Jan Benitez is a freelance writer for hire who provides actionable and useful web content to small businesses and startups. In his spare time, he religiously watches professional wrestling and finds solace in listening to ’80s speed metal. Read Christopher’s Full Bio

Читайте также:  Copy directory with all files linux

Запуск программ Linux в Windows Running Linux programs on Windows

Для запуска программы Linux в Windows возможны следующие варианты: To run a Linux program on Windows, you have these options:

  • Запуск программы «как есть» в подсистеме Windows для Linux (WSL). Run the program as-is on the Windows Subsystem for Linux (WSL). В WSL программа выполняется непосредственно на оборудовании компьютера, а не на виртуальной машине. In WSL your program executes directly on the machine hardware, not in a virtual machine. WSL также поддерживает прямые вызовы файловой системы между системами Windows и Linux, устраняя необходимость в SSL-транспорте. WSL also enables direct filesystem calls between Windows and Linux systems, removing the need for SSL transport. WSL разработана как среда командной строки и не рекомендуется для приложений, интенсивно использующих графику. WSL is designed as a command-line environment and is not recommended for graphics-intensive applications. Дополнительные сведения см. в документации по подсистеме Windows для Linux. For more information, see Windows Subsystem for Linux Documentation.
  • Запуск программы «как есть» на виртуальной машине Linux или в контейнере Docker на локальном компьютере или в Azure. Run the program as-is in a Linux virtual machine or Docker container, either on your local machine or on Azure. Дополнительные сведения см. в разделах Виртуальные машины и Docker в Azure. For more information, see Virtual Machines and Docker on Azure.
  • Компиляция программы с использованием gcc или clang в средах MinGW или MinGW-w64, которые предоставляют слой преобразования системных вызовов Linux в системные вызовы Windows. 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.
  • Компиляция и запуск программы с использованием gcc или clang в среде Cygwin, которая предоставляет более полную среду Linux в Windows по сравнению с MinGW или MinGW-w64. 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.
  • Ручное портирование кода из Linux и компиляция для Windows с использованием Microsoft C++ (MSVC). Manually port your code from Linux and compile for Windows using Microsoft C++ (MSVC). Этот подход подразумевает рефакторинг кода, не зависящего от платформы, в отдельные библиотеки, и последующее переписывание специализированного кода, относящегося к Linux, в код для Windows (например, для API-интерфейсов Win32 или DirectX). 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.

—>

How to Install Linux on your Windows Computer

Are you a Windows user who is curious to try Linux (Ubuntu in particular) because you have heard so many good things about the OS from your geek friends?

There are two ways to use Linux on a Windows computer. You can either install the full Linux OS alongside Windows, or if you are just starting with Linux for the first time, the other easy option is that you run Linux virtually with making any change to your existing Windows setup.

The former option will offer the best performance because all your system resources will be available to Linux but the latter option is absolutely risk-free and therefore recommended for novice users. You’ll be able to test drive Linux but without changing a single file on your Windows computer.

Running Linux with Windows — Your Options

Let’s look at some of the easiest ways to use Linux on a Windows computer. Linux is available in multiple flavors (your friends may call them Linux distros) but here, let’s focus on the desktop edition of Ubuntu, perhaps the most popular and actively developed Linux distribution.

A: Test-Drive Linux Online as a Web App

Perhaps the easiest way to try Linux on your Windows Desktop is inside your web browser. Go to edubuntu.org, fill that simple form and within a minute, you’ll have the full version of Ubuntu Linux running on your desktop inside a Java applet.

Читайте также:  Подключение по ip адресу linux

There’s absolutely no need to download or install anything on your computer and a single session can last up to two hours. You get access to all the features that are available in the standard desktop edition of Ubuntu Linux including the ability to download and install new packages from the Linux repository.

B: Run Linux from a USB Stick or a CD

The most popular option to test-drive Linux on Windows is a LiveCD. Though it says “CD,” you can also use a USB Flash Drive as a LiveCD (without having to burn a CD).

To get started, download the latest version of Ubuntu to your desktop. This is an ISO file (also known as a CD image) that is around 650 MB in size. If you don’t have a great Internet connection, you can always borrow the Ubuntu CD from a friend (yes, its perfectly legal) or order a readymade live CD from OSDisc.com.

Once you have Ubuntu ISO image file, grab an empty USB disk and use UNetbootin to quickly turn that USB drive into a bootable Ubuntu disk for Ubuntu without having to burn a CD. Insert the bootable USB flash drive into your Windows computer and reboot. If this doesn’t work, go to the BIOS boot menu and change the boot sequence.

You should see an option at the boot menu that says “Try Ubuntu without any change to your computer” – choose that and you are good to go. Once inside Linux, you can install new programs, create files and everything else that you normally do at a computer though your changes won’t be written to the disk.

The Ubuntu portal has more details on creating and troubleshooting a LiveCD.

C: Run Linux in a Virtual Machine

The term virtualization may sound very geeky but in simple English, all it means is that you can another OS over an existing OS. For instance, you can run Windows on a Mac or you may install Linux on a Windows 7 machine using virtualization software.

To get started, download and install the free VMware Player on your Windows desktop. Then download the VMware image for Ubuntu and extract the zip file (I use PeaZip). Now double-click the Ubuntu.vmx file that you just extracted and the Linux virtual machine will load inside the VMWare Player. Simple!

Technically, Linux will be the “guest” operating system while “Windows” will be considered the host OS. And other than VMware, you may also VirtualBox to run Linux inside windows. The VirtualBox installer and the Ubuntu Linux images for VirtualBox for can be downloaded for free from oracle.com.

D: Install Linux like a Windows Software

Wouldn’t it be nice if you could install Linux like a native Windows app – something like Microsoft Office? For instance, if you have Office running on Windows, you can always uninstall the software later without affecting any other Windows programs or system settings.

Meet Wubi — short for Windows-based UBuntu Installer — a tiny utility that will help you install Ubuntu Linux alongside any other Windows application. Run the installer, choose a password for your Linux environment and the software does the rest.

It will download the necessary Linux ISO from the Internet and will install it on your machine. Alternatively, if you have previously download the ISO, you can just place the .iso file in the same folder as Wubi and it will pick it up.

Now the next time you restart / reboot your computer, it will offer you a choice of Linux (Ubuntu) and Windows. This is a real Linux installation and thus the overall performance should be good as well. If you ever want to uninstall Linux, simple boot into Windows, go to the Add-Remove problems and uninstall Wubi.

E: Run Linux inside the Web Browser

If you are just starting to learn Linux and are looking for an easy way to practice the various Linux commands, check out the very-impressive JSLinux project.

This is an emulator that lets you use Linux inside your web browser. You may write shells scripts using Sed and Awk, master regular expressions, play around with popular text editors like Vi and Emacs, look up man pages of various Linux command and much more – all inside your browser.

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