DEV Community

Tim Apple
Tim Apple

Posted on

21 3

Linux commands that work in Powershell by default.

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. In the future I will do a write up on each one individually. For now, let's just get familiar with them.

  • cat - Lists contents of files to the terminal window.
  • cd - Change directory
  • clear - Clear the terminal window.
  • cp - Copy file
  • curl - Retrieves information and files from URLs or internet addresses.
  • date - Shows current date
  • diff - Compares two text files and shows differences between them.
  • echo - Prints a string of text in the terminal window.
  • exit - Exit your current shell.
  • finger - Shows information on user.
  • find - Search for files.
  • history - Brief list of the last few commands you have used.
  • kill - Kill a running process.
  • ls - List the files and folders in the current directory.
  • man - Show man pages.
  • mkdir - Create a directory
  • mv - Move a file or directory.
  • ping - Tool to help verify network connectivity.
  • ps - List running processes.
  • pwd - Prints current working directory to the terminal.
  • rm - Remove a file.
  • rmdir - Remove a directory.
  • ssh - Connect to a remote computer.
  • tar - Create archives.
  • wget - Downloads files served with HTTP, HTTPS, or FTP over a network.
  • whoami - Find out who you are logged in as.

Please play around with these in your terminal. Let me know if there are any I may have missed and I can add them.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (14)

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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay