Monday, 17 February 2014

Back to Basics: How to use the Windows Command Line

Those of us that have worked with computers for most of our lives, take the command line for granted. We know it exists, we know basically how to use it, and we know how to find the commands we need even if we can't remember them.

But, not everyone knows how to use the command line. I've had quite a few questions on the various courses I conduct because people have no familiarity with the command line. And the worst part was, I could not find a good resource to send them to, in order to learn the command line.

As a result, I created a short 6 minute video that shows how to start the windows command line, change to a specific directory, run some commands, and how to find out more information.



Start Command line by:
  • clicking on start \ "Command Prompt"
  • Start \ Run, "cmd"
  • Start \ search for "cmd"
  • Win+R, "cmd"
  • Windows Powertoy "Open Command Window Here"
  • Shift + Right Click - "Open Command Prompt Here"
  • type "cmd" in explorer (Win+e, navigate, "cmd")     
  • Windows 8 command from dashboard
Change to a directory using "cd /d " then copy and paste the absolute path from Windows Explorer.

Basic Commands:
  • dir - show directory listing
  • cd .. - move up a directory
  • cd directoryname  - change to a subdirectory
  • cls - clear the screen
  • title name - retitle a command window
  • help - what commands are available
  • help command - information on the command

If anyone wants more videos like this then please either leave comments here, or on YouTube and let me know. Or if you know of any great references to point beginners at then I welcome those comments as well.

4 comments:

  1. Wow, this takes me on a trip on the Way Back machine. I think one of the most used commands is definitely 'dir'. But a lot of people do not know about the command line switches with the CMD window itself (or as us olde timers call it, the DOS window... yes, I'm showing my age).
    And that is where you really get some power with the base command itself. For example; dir has switches that allow some neat tricks as you know. My favorite is 'dir /s /p /oen' which translates into show the directory structure (including subdirectories) a page at a time and sort on file extension first and then name. Great for finding all those '.log' files in one compact listing. This along with the 'more' command when looking at text files is good to know.

    Another thing is the wildcard capabilities along with them. And eventually using redirects and pipes to place output where you want it (like redirect 'dir' to a file).

    So a couple more things to teach these "kids" about how to really get into the OS and do some things really fast. Also, some of these commands translate over to UNIX/Linux fairly well too.

    ReplyDelete
    Replies
    1. Thanks for the informative comment.

      And for anyone reading

      /s (display files in directory and all subdirectories.
      /p pause after each screenful
      /o (order by) e (extension) n (name)

      For bonus points, people might want to try "dir /s /oen > output.txt" which outputs all the results into output.txt

      Then "type output.txt" to see the file contents.

      But don't try it on your root directory, OK.

      And remember ctrl+c to stop commands when they are running.

      Enjoy

      Delete
  2. haha... Great article Alen.... Although it's been close to 2 decades that I have been using a PC, still more often than not, to find the very basic of commands, I have to head over to Google to know the exact syntax... this one is very useful for people like me ;)

    Cheers,
    Amandeep Singh

    ReplyDelete
  3. Yah really, I also cannot remember various commands so I have saved a pdf on my pc to check for various commands. Command Line is also taught in various schools and college level these days which good.

    Students come to know that there is still something basic black screen in the PC

    ReplyDelete