A beginners guide to the Command Prompt

Command Prompt small imageMost Windows users don’t know what the Command Prompt is or how to use it. This is a beginners guide to using the Command Prompt.

What is the Command Prompt? The Command Prompt is a native Windows program that lets you execute commands without using a GUI. You can accomplish pretty much every task you can do using Windows and the mouse from within the Command Prompt. The Command Prompt gets its roots (arguably) from a combination of MS-DOS and UNIX. Consider it “Windows without the windows. ” I will provide you with a beginners tutorial of some simple commands to familiarize you with the Command Prompt.


The first step is to actually open the Command Prompt. You can do this by going to Start >> All Programs >> Accessories >> Command Prompt. You should get a screen that resembles mine below:
Command Prompt image

You should see a blinking cursor after a line that says C:\Documents and Settings\username. This is used to identify what directory you are currently in. This also brings us to our first three commands cd, dir, and .. (two periods). Let’s start with dir — “dir” stands for directory. Type dir into the command prompt to see a listing of the directories and files located in your “username” directory.

After you type in dir you will see a listing of several folders including Desktop, Favorites and My Documents. “CD” stands for change directory. So in order to change to our “My Documents” folder we need to type cd My Documents, give it a try. You will now notice that your path has changed to C:\Documents and Settings\username\My Documents. To see a list of all the files in your My Documents directory type dir. If you want to move back into your username folder use the “back” command. You can move back by typing cd .. See the image below:
Command Prompt image


That’s a good introduction, but lets actually go over some useful commands: copy, del, mkdir, rmdir, ren. “CP” stands for copy and it can be used to copy individual files from one location to another. To copy a file, type copy filename destination. So if you had a file named test.txt in your My Documents folder and you wanted to copy it to the Desktop you would type copy test.txt ../Desktop

The del command stands for delete. So to delete the test.txt file from your desktop type cd ../Desktop and then type del test.txt
Command Prompt image 2

“mkdir” stands for make directory. To make a new folder type mkdir foldername

“rmdir” stands for remove directory. To remove a folder and its contents, type rmdir /s foldername
Command Prompt image 3

“ren” stands for rename. To rename a file type ren oldfilename newfilename

Let’s move on to a more difficult task. Let’s copy our My Videos folder from My Documents to the Desktop. To do this, navigate to your username directory by typing cd .. until you get there. Now type cd My Documents to get into the My Documents directory. To copy the My Videos directory to the Desktop you need to type xcopy “My Videos” “../Desktop/My Videos” /s /i
Command Prompt image 4

Here’s a summary of what you can now do using the command prompt:
cd change directories

dir see a list of all the files in one directory

copy copy a file from one location to another (don’t forget to include the file extension)

del delete a file (don’t forget to include the file extension)

mkdir make a new folder

rmdir remove a directory and its’ contents

ren rename a file

xcopy /s /i copy a directory and its contents from one location to another

NOTE: To see a list of many commands, just type help into the command prompt. To see a detailed list of all related commands type command/? so to see all the details of xcopy type xcopy/? If you would like to run an executable like Mozilla Firefox navigate to the directory containing the executable and simply type it in. So type: C:/Program Files/Mozilla Firefox/firefox.exe

If you would like to learn more about the command prompt here is the documentation from Microsoft. What other commands do you think are useful for beginners? Tell your side in the comments.

Trackbacks & Pings

Comments

  1. i like the guide. i was trying to learn command prompt from so many days now i have a good guide. thanks

  2. Thank you so much.
    Best guide that I found to Command Prompt.
    Really nice job.
    Many thanks once more.

  3. Hi,

    Your guide is very good indeed, but I have a doubt… I have to run several instances of an application in a Windows server 2003. Each instance of this application should run by launching a batch command file and thus a “command prompt” window stays open. I would like to identify each “command prompt” window for example by numbering them. Instance one -window 1, instance 2-window2…Do you know how to do it ?
    Thanks,
    Marmelo

  4. Marmelo: The DOS command you are looking for is “title.”

  5. The above information on command prompt commands was excellent ! Can any one help me to find out how do I rename all the files in a folder n its subfolders with “ren” command or is theit any other way out ?
    Thank you !

  6. Ok heres one for you, I want to create a batch file that creates a new folder on the ‘Desktop’ called ‘Tidy Desktop’ but then moves not only all files but also any other folders to the newly created ‘Tidy Desktop’ folder.

    I can do everything but move any folders… This is my code thus far:

    @ECHO OFF
    MD “%systemdrive%\Documents and Settings\%USERNAME%\Desktop\Tidy Desktop”

    MOVE “%systemdrive%\Documents and Settings\%USERNAME%\Desktop\*.*” “%systemdrive%\Documents and Settings\%USERNAME%\Desktop\Tidy Desktop”

    Any help would be fab :)

  7. TinnyFusion: I think you are out of luck doing this with out-of-the-box DOS commands. The MOVE command will operate on folders, but it appears to only work for ones that are explicitly named (no wildcards), and it doesn’t actually move them (just renames them). You MIGHT be able to do it with a pair of commands (XCOPY and DEL). You’ll want to be extremely careful not to delete the shortcuts on your desktop. XCOPY has a way to pass in a list of exclusions (the shortcuts are *.LNK files), but DEL does not.

    You’ll probably have better luck with an archiving tool (Winzip, 7-Zip, etc.). Instead of moving the files and folders to a “tidy” folder, move them into a “tidy.zip” archive. Those tools all have options for deleting the original files after they have been ZIPped up, so you can do it in one stroke. If you want, you can then turn right around and unzip the files into a tidy folder, of course.

  8. PLS HELP ME MY PC CRASHED AND NOW SAYS HAL.DLL IS MISSING. IVE TREIED TO USE MY BACKUP BUT TO NO AVAIL. I AM NOW IN RECOVERY CONSOLE AND WANT TO KNOW HOW TO COPY THE MY DOCUMENTS TO CD IF POSSIBLE SO I DONT LOSE ALL MY A LEVEL WORK. PLS HELP ASAP IM DESPERATE.
    IM CURRENTLY AT C:\
    BUT IT DOESNT SEEM TO RECOGNISE
    C:\CD DOCUMENTS AND SETTINGS

  9. Hey Chris,

    I would recommend slaving your harddrive under another machine and backup your files. Don’t format your disks.

  10. Helpful
    thanks.

  11. This is great i am only 13 and i can do this stuff now thanks to your guide

  12. This is really good. Thanks. For some tricks & tips go to www.Sikkaspeaks.Blogspot.Com

  13. hey i have a problem, when i copy a folder to the desktop, cp says it copied, but i don’t see it anywhere on my desktop, why won’t it work?

  14. can you open locked files with command prompt

  15. THIS WAS USEFULL

  16. This is deffinatly the best guide on the web!! so clear and got right to the point, learnt all this stuff in a few hours and am craving more. perhaps you could send me a few more commands to try out??

    also i think you could try to explain the xcopy more clearly and show the different options( or at least some of them!) as that would have been very useful.

    But you have done an outstanding job, im only 14 and got it all very quickly :)

  17. OPENING CMDPROMPT APPEARING LIKE THIS “C:\Documents and Settings\KC” …….I WANT CHANGE TO E:\DRIVE……HOW TO DO IT

  18. Hey when ever i try to copy or delete something it says “the system cannot find the file suspected” I’m not sure what im doing wrong.

  19. Why is everyone saying “I’m only 13/14?”. I’ve written an Operating System (incl. bootloader and kernel) from scratch, in C and x86 assembly. And I don’t even consider myself 1337. Get a life.

    And if you want to know why I am here it’s because I use GNU/Linux (Fedora 10) as my host development environment and the Windows terminal (I mean “Command Prompt”) is inferior to even the default terminal provided with a standard GNOME/KDE desktop.

  20. By the way, I’m 13.

    (NOT only 13; 13 isn’t too young to start writing an OS.)

  21. Worked great, how to you activate a file in CP?

  22. Firstly ty for this guide, i may of learned this already but this was a more clearly and much better done site and was actually easy to understand so easy id say even a 8 year old could learn if they found this site, which leads onto my second thing i agree with Zach, who the hell cares if ur 13 or 14 and could understand this it just means it was an excellently done web site, not that ur actually smart

  23. I want to make a printable copy of a music file on a directory I’m linked into on a server in My Network Places- can i do this and if so how do i run the command to get there? Thanks

  24. how to format other local disk (say F:\ ) using command prompt

    Answer me on vankan_dan@rediffmail.com

  25. hey, how do you retrieve manually deleted files via command prompt? is that possible somehow? mail your answer please at csorila17@gmail.com..thanks..

  26. hi..how would you retrieve manually deleted files via command prompt? is that possible somehow? thanks! please mail answers at csorila17@gmail.com..please? thanks!

  27. How do you open command prompt on the school’s network??

  28. Bisa nggak sih Program dBase III+ dan Turbo Basic di jalankan di command prompt? Tolong ksih tau ya!!! Please

  29. Thanks, great guide. I’m interested in more attribute commands, like xcopy /s /i etc.

    @Zach: “Why is everyone saying “I’m only 13/14?”. I’ve written an Operating System (incl. bootloader and kernel) from scratch, in C and x86 assembly. And I don’t even consider myself 1337. Get a life.
    And if you want to know why I am here it’s because I use GNU/Linux (Fedora 10) as my host development environment and the Windows terminal (I mean “Command Prompt”) is inferior to even the default terminal provided with a standard GNOME/KDE desktop.” - spoken like a little “1337″ punk. Why are you even reading or commenting on this? Lol, sounds like you need to “get a life”. You can write an OS but can you talk to a girl? Haha, poor little guy.

  30. Love it, it is educative.
    Thanks

  31. hey i really loved the tutorial… it ll be very helpful 4 me to learn cmd prompt…. Thanx a lot Bossss….

  32. Great advice, many thanks. Been working on getting better aquainted with the cmd uses but been struggling a little with the correct syntax methods. Your advice has certainly provided me with a few more pointers in the right direction.

    Was also wanting to ask your self, im currently experiencing a endless invasion of hacks, which are modifying, infecting or finaly corrupting all my home computer systems. Quite possibly I expect from a neighbouring property possibly running the linux operating system to gain access. Have you any pointers on usefull cmd commands I can try, that may prove usefull to myself in the identification of there access methods? Got to in some way be wireless network related. Any thing you can suggest is greatly appreciated. This problem is turning into a reoccurring battle nd is starting to become somewhat Costly to myself. Once again, many thanks.

  33. I’m confused…I tried to do the stuff right at the beginning of the tutorial, and it is telling me ‘a required privelege is not held by the client’…what???! This is my own laptop..what am I doing wrong?

  34. First,I was confused how to use command prompt.When I read the tutorial I can use it so fast and correctly.Thanks for help.!!!!!!!!!!!!!!!!!!!!!!!

  35. tujhe itni si bhi baat pata nahin………..

  36. i need to know how to use the cmd to detect ,transfer and other useful commands with exaple which will works in the windows 7

  37. hi, this was brilliant resource i have been trying all over to get this beginner material i am teaching myself CMD and i am very grateful.

  38. How I go to F drive using cmd… ??? I try with cd like
    cd F:\BANGLA
    I use windows 7

  39. Thanks for the tips, those were great. It just says the things were in syntax command.

  40. made me lol when i saw how many of these coments are about 13 year olds who think they’re now 1337 hax0rs now they can copy using cmd….wtf is up with the young people these days

  41. badream wrote:

    “made me lol when i saw how many of these coments are about 13 year olds who think they’re now 1337 hax0rs now they can copy using cmd….wtf is up with the young people these days…”

    Good technology is timeless.

  42. Please help me soon , i want to change the proxy settings ( lan server number and port number ) in the internet >tools >connection .how to make command prompt for that ? Please please . . .

  43. quite not so difficult but the procedures need to be listed for easier learning

  44. this site has helped alot :) i wanted to know if you could tell me how i could find out the passwords saved on my computor.

    i forgot them

  45. the face looks unhappy but it is actualy meant to be happy

  46. How do we open files directly? Say if i wanted to view the photo straight from command prompt.

  47. Thanks

  48. I need to take ownership of files for deletion but I’m the administrator and getting denied. can anyone help with command prompt?

  49. good it is useful

  50. I want to know all the commands in the cmd prompt and also the commands from DOS ,how can i get them ,please help.thanks

  51. Wow! fabulous its helps me a lot………….

  52. Hey, This was great for beginners. Compared to some of the ages listed, I guess I am a little older than people who are starting out, but I am really interested in learn this stuff. Maybe something for the next step? I cant find anything that explains as well as you.

  53. wow nice guide it helped me im 13 but i already am good at this now i hacked in to games and crashed servers using this thanks for the guide its really goood
    if u wanna know how to crash a computer type this in
    crash
    crash
    crash
    crash
    crash fail

    and go to cmd and put color z if u want the color to be red for ex it will say 4 then u put color four into the cmd and enter voila there u go

  54. It’a a great tutorial…..really helpful…#thanks.

  55. thanks
    its very usefull me
    i need more notes

  56. Can any body tell me How to locate the ip address of any computer in network???

  57. thanks you are helping the new generation thank you very much

  58. Thank you for the Information+Can I upload this in YouTube as a Video with the name of this website? Please reply. My E-mail is navaneethbhanu@gmail.com.

  59. Greetings and not tired …
    I have a question about the cmd:
    We know that in C to display the ASCII code for the letter “A” command
    printf # 65 OR cout # 65 is used.
    I would like to know how this is done in cmd?
    For example, the command echo # 65 is wrong!
    What is the correct command?
    Is not there a command that contains an ASCII code of the show?
    Please send e-mail your answer to question
    I’ve used your site
    Thank you very much
    Be
    Thank you
    shzaa123@gmail.com

  60. Thank you brother

  61. Thnx……….it is really useful 4 me……

  62. pls tell me about how to use cmd & ip config in xp window. pls tell me simply language. it’s very urgent sir!

  63. my email adress is pardeep143aggarwal@gmail.com

  64. nice

  65. Hi,
    How do I use the cd command to move from c:
    to c:\documents and settings ?

    I have tried cd “c:\documents and settings ”
    I have tried cd c:\documents_and _settings
    I get parameter format not correct or,
    too many parameters.

  66. Hi,
    I would like to know how to copy the files available in multiple folders to a separate folder using Commandprompt. The formats of the file is .pdf
    Thnx
    Ravi.G

  67. i need to click on buttons of java applications

  68. I need to check if a command execution was sucessful/not in cmd prompt, can anybody help me with this??
    For ex - if I type ‘clinfo’ cmd it displays the info but i need to capture the result of ‘clinfo’ cmd i.e., success/fail onto a script….

  69. cp command not woking….instead “copy” is..

    when i copy file…it says 1 file copied… but it never show that file there???

  70. i’m not able to access other drive for eg: cd e:) this is not working… plz help me out…

  71. Great job

  72. hi
    im a new bigginer or youll rather say a dummy, so please can you send me some note regarding command prompt.
    an introduction guide would be very apprecited,
    cheers
    frankie

  73. Very good guide, it started me to get interested in cmd. I would like to learn how to hack a website or facebook id using cmd

  74. @pavan
    I’ve gotten tripped up by this before too. You don’t use “cd” to change drives. That’s only for changing directories. To change drives simply type the drive letter. so in your case just type:
    e:

    Hope that helps…

  75. thnx man god bless u

  76. HOW TO GO BACK IN CMD. (to go in previous folder)

  77. thanx alott…..much appreciate it…vry useful for a newbie!!

  78. I so love this page

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.