DEV Community

Linux commands that work in Powershell by default.

Tim Apple on May 22, 2020

Some people may not realize there are a lot of Linux commands that work within PowerShell. I thought I would list some of them for people to try. I...
Collapse
 
bryrod profile image
Bryan Rodriguez

It’s a great resource. Recommend that you change the commands with markdown code using the back ticks. Also, believe if you run Get-Alias * , you should get a list of all these Linux native commands that have been used to represent a PowerShell command.

Collapse
 
webreflection profile image
Andrea Giammarchi

what about operators such as | (pipe) > (create from scratch) or >> (append to file or create)?

also, if sed or grep or awk would work in there too, I might update some of my bash scripts to work in PowerShell too. Thanks.

P.S. it'd be cool if ${1} and other variables are reachable as well, having just commands but no way to cross send parameters via shell is 1/3rd as useful.

Collapse
 
darthwalsh profile image
Carl Walsh

These aliases trip me up. If I type rm -r -f * I get an error about ambiguous arguments between -force or -filter, and I need to change the flag to rm -r -fo *.

I also lost half an hour figuring out why curl was respecting the system default proxy in one terminal window but not the other. After that I turned off a bunch of aliases.

Collapse
 
bryrod profile image
Bryan Rodriguez

Did you try rm -rf <file or dir>? That’s what I usually use if I’m in PowerShell.

Collapse
 
darthwalsh profile image
Carl Walsh

I tried it; I get Remove-Item : A parameter cannot be found that matches parameter name 'rf'. The Remove-Item cmdlet doesn't have a param starting with rf... Is your rm not aliased to Remove-Item?

Collapse
 
nathanstrutz profile image
Nathan Strutz

I was surprised to learn I could create a file via touch. It's not quite as cool as PowerShell's New-Item but it totally worked. Touch didn't make the list here but it got me thinking and that's how I found this post. Thanks for writing it!

Collapse
 
paulngumii profile image
Paul Ngumii

Excellent! thank you for listing these, just started using the new Windows terminal and I have much love for it

Collapse
 
mohan023 profile image
Mohan Sharma

What about netstat? That also works in linux and windows.

Collapse
 
ablertarock profile image
Caedmon Craig

I generally use ifconfig...

Collapse
 
bbaassssiiee profile image
Bas

Really useful, not: finger.

Collapse
 
heytimapple profile image
Tim Apple

finger works for me? weird. Here is the doc for using it from MS.

docs.microsoft.com/en-us/windows-s...

Collapse
 
bbaassssiiee profile image
Bas

Who runs a fingerd nowadays?

Thread Thread
 
heytimapple profile image
Tim Apple

To be honest, I have no clue. But it it worked as I ran through all the commands I could think of.

Collapse
 
danarj profile image
Danar

some of them work in cmd also like ping, cd, ssh and mkdir.