Command line tricks

Posted on 5/3/2013 @ 2:23 AM in #Bak2Basics by | Feedback | 1676 views

I am a self confessed Command Line Junkie. Here are a few tricks I use commonly that I can think off the top of my head.
These apply to both DOS and PowerShell.

1. Find a file on your hard disk - (This beats the Search doggie in Windows)
      dir filename /s

2. Find a file on your hard disk without all the directory info goo -
      dir filename /s/b

3. Create a list of files, say your MP3s to share with a friend? (disclaimer: don't do this piracy crap)
    dir *.mp3 /b > filelist.txt

4. Find a directory -
      dir dirname /s /ad

5. Move between directories easily
     C:\Documents and Settings\Sahil Malik>pushd .
     C:\Documents and Settings\Sahil Malik>cd \
     C:\Documents and Settings\Sahil Malik>

6. Hit Tab for directory/filename completion

7. Press F7 for a previous command list. User Cursor keys to select the command you need.

8. View all environment variables

9. View only system variables that start with W
Set W

10. View a particular env. variable

11. Find what process has opened what port
netstat –noa

12. Widen your command prompt.
mode 120,100

13. View your TCP/IP settings.
netsh interface ip show config

14. Weird looking colors
color 8f

15. Find a string in a list of files, for example "Foo" in all .cs files in your project tree:
findstr /i /s "foo" *.cs
(You might know that the windows search doggie does an awful job at search thru files, I think it just ignores files with recognized extensions, so .cs will be ignored YUK).

16. Refresh the netbios nametables:
nbtstat -R

Sound off but keep it civil:

Older comments..