Linux which command in windows

4 Ways to Run Linux Commands in Windows

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 you don’t have a Linux laptop but a 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 commands 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

Run Linux Commands In 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 method to run Bash commands on Windows.

1. Use Linux Bash Shell on Windows 10 with WSL

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. Using Bash on Windows 10You 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. Install Windows Subsyetm for LinuxPlease refer to this tutorial about installing Linux bash shell on Windows.

Читайте также:  Check port usage linux

2. Use Git Bash to run Bash commands on Windows

Git Bash

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

Cygwin Shell

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.

4. Use Linux in a virtual machine

Ubuntu Running In Virtual Machine Inside Windows

Another way is to use virtualization software and install Linux in it. This way, you install a Linux distribution (with a 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. You can follow this tutorial to learn how to install Linux in 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.

Источник

What is Windows’ equivalent of the «which» command in Unix? Is there an equivalent PowerShell command?

In Linux, we have the «which» command to find out the path of an executable.
What is its Windows equivalent? Is there any PowerShell command for doing that?

6 Answers 6

Newer versions of Windows (I think Windows 2003 and up) have the where command:

C:\>where ping C:\Windows\System32\PING.EXE 

And for PowerShell, explicitly add the .exe suffix:

PS C:\>where.exe ping C:\Windows\System32\PING.EXE 

where /r c:\ fileName adding the /r c:\ allowed me to perform a recursive search starting at the root of the C drive using Windows 7 Professional it seems to not be in access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…

in Powershell you should say where.exe ping because where is by default aliased to Where-Object cmdlet which is completely different story

Yes, Get-Command will find all commands including executables:

If you want to limit the commands to just executables:

PS\> Get-Command -CommandType Application 

Will find all exes in your path. There is an alias for interactive use:

PS\> gcm net* -CommandType Application 

To get the path of an executable, you can use the Path property of the returned object. For example:

PS\> (Get-Command notepad.exe).Path 

For more info, run man Get-Command -full .

where.exe explicitly rather than where works for me in PowerShell:

PS C:\Users\birdc> where ping PS C:\Users\birdc> where.exe ping C:\Windows\System32\PING.EXE 

In addition to user10404, the help command will work on aliases, so you can use the same command name (gcm) for help and interactive use:

help gcm -Parameter * # or man gcm -Par * 

If you want to make it short, create a one line which.cmd file with the content

This will search the first parameter (%1) fed to the script and display the full path of found file. Good place to put this script in windows 10 is %LOCALAPPDATA%\Microsoft\WindowsApps\which.cmd

Читайте также:  Linux mint for iphone

And you get your which command in path.

c:\>which cmd.exe c:\>echo C:\Windows\System32\cmd.exe C:\Windows\System32\cmd.exe 

Источник

Windows equivalent of which command in linux

Can you please tell me what is Windows XP equivalent of “which” command in Linux? I have tired ‘where’, but it does not work on Windows XP.

4 Answers 4

There is no equivalent in Windows, but you can try one of these two substitutes:

or this guy created a script too:

I just found this, which also had another answer, not accepted, but with a +50 score: stackoverflow.com/questions/304319/…

There are several possibilities that you can choose from:

  • Use a true POSIX which command. The SFUA utility toolkit, whose tools run in the Subsystem for UNIX-based Applications that comes right there in the box with Windows 7 Ultimate edition and Windows Server 2008 R2 (For Windows XP, one can download and install Services for UNIX version 3.5.), has a which command, along with some 300 other POSIX tools. Its Korn shell also has the type built-in command, which of course understands the shell’s own aliases. It comes in both x86-64 and IA64 flavours as well as x86-32. The programs run in Windows’ native proper POSIX environment, rather than with emulator DLLs (such as cygwin1.dll ) layering things over Win32.
  • Use a Win32 port of which . Oft-mentioned are GNUWin32, cygwin, and unxutils.
  • Use a replacement command interpreter and use its built-in facilities.JP Software’s TCC/LE is one such. It has a built in WHICH command, which understands TCC’s aliases and executable extensions.

A bit overkill, but for completeness: Cygwin will give you which on Windows.

This is actually answered on SE, in great detail:

Maybe it should be merged to Superuser, instead marked off topic on that site.

You must log in to answer this question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

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