Linux Users Should Use the Windows 7 Powershell (LS, MAN, PS on Windows 7)


When you start to become familiar with Linux, you tend to look for similar functions on Windows 7. Heck, the last time I opened up a command shell the first thing was that I entered PS AUX. Obviously, that did not work ;) Here’s how you can use some Linux functions on Windows 7.

Windows 7 PowerShell

Short Windows 7 PowerShell Intro

1. Open the Windows Powershell, on the Start Menu it’s listed under Programs/Accessories/Windows PowerShell/Windows PowerShell

2. Enter PS which is now similar to Linux listing all processes that are currently running.

Windows 7 Powershell List All Processes
(Loving the blue background of the PowerShell!)

3. Now, what’s very cool, other commands like man also work. So let’s do a quick man PS to learn more about the PS syntax in the PowerShell. As you can see PS accepts the parameter ID to filter processes by ID. Process VLC has the ID 5144 for example, so let’s filter for that ID:

PS -id 5144 grabs the VLC process:
Process List Filter By ID

4. Now, that’s not very useful. How about a sorted list with the processes using the most memory at the top. Do that you have to use the paramter “sort-object” to sort stuff and the argument WS (which is the memory). Use either descending or ascending, depending on your needs.

ps | sort-object WS –descending

5. Ok, so you may ask what the fuss is all about? The task manager can do the same for you without entering all those commands. But what if you want to write a Windows Powershell script that kills a specific process whenever it reaches a certain memory value? The task manager can’t do that, unless you use a 3rd-party task manager for Windows 7 that includes such a feature.

6. Now, just to show you how similar the Windows PowerShell is to the Linux shell, we are going to export the results into a text file. Simply enter:

ps | sort-object WS –descending > C:/temp/memory.txt

7. Unfortunately, grep is not available, the Windows equivalent is findstr (a tad longer, but oh well)

Windows 7 Grep Alternative

8. So, let’s say you want to “grep” only a specific value on that list of processes you can use findstr. Keep in mind, that findstr is case-sensitive! So PS | findstr VLC won’t work!

That was a little introduction to the Windows PowerShell. I hope you find this interesting and when I have time I’ll write some scripts to grep some important value at specific times and publish them on this site. So, stay tuned!

Basic Linux Commands That Work In Windows PowerShell

man
ps
ls
> (output stuff into … /path/to)
..
List will be updated

Basic Linux Commands Equivalents

Linux – Windows
grep – findstr

List will be updated


Or you might like these sexy wallpaper, tweaks and themes:

Written by oliversk Thursday, December 2nd, 2010

Was it helpful? Please bookmark it and spread the word

delicious   facebook   google   twitter  

You love Windows, Gaming and everything digital? Great, we too! We have thousands of great Windows 7 themes, registry tweaks, tutorials, so please use our search box if you look for anything specific. If you have some awesome desktop themes, tips or want to write for us, then drop us a mail: win7themes at googlemail.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>