loading...

Linux commands that work in Powershell by default.

heytimapple profile image Tim Apple ・1 min read

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.

Discussion

pic
Editor guide
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
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
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
bbaassssiiee profile image
Bas Meijer

Really useful, not: finger.

Collapse
heytimapple profile image
Tim Apple Author

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 Meijer

Who runs a fingerd nowadays?

Thread Thread
heytimapple profile image
Tim Apple Author

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

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
danarj profile image
Danar

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