Command Prompt - How to use the simple, basic commands

Geeks and experts all love the Command Prompt because of the advanced tasks and commands you can run in it. But that doesn’t mean that it’s only useful for experts - after all, every expert was a novice in the beginning. And Command Prompt is not built only on advanced commands, but also on simple commands designed to perform basic operations. In this article we will show you how to execute commands like changing the working folder, viewing the contents of a directory, creating and renaming folders, copying, deleting files and folders, and launching any application from the Command Prompt. We will also see how to get help when using this tool.

NOTE: The information shared in this tutorial applies to Windows 10, Windows 8.1 and Windows 7. Note that, for simplicity, we will use screenshots taken only in Windows 10.

How to navigate between folders

The first command from the list is CD (Change Directory). This command enables you to change the current folder or, in other words, to navigate to another folder from your computer.

For instance, the command CD\ takes you to the top of the directory tree. To see how it works, after you open the Command Prompt, type cd\ and press Enter on your keyboard. You will see that the CD\ command takes you to the top of the directory tree (in this case to the “C:” drive).

Command Prompt, cmd, Windows, basic, commands, files, folders

NOTE: Command Prompt is not case sensitive, meaning that commands can be typed with capital letters, lowercase or any combination of them. The commands CD, cd or Cd will all work in the same way.

Going back to the “CD\” command, now you are working on the root of the “C:” drive. If you need to go to a specific folder from this drive run the command “CD Folder”. The subfolders must be separated by a backslash character: “\”. For instance, when you need to access the System32 folder located in C:\Windows”, type “cd windows\system32\” as shown below, and then press Enter on your keyboard.

Command Prompt, cmd, Windows, basic, commands, files, folders

When you need to go to one folder up, use the “cd..” command. Let's assume that you want to go back to the Windows folder. Type “cd..” and press Enter on your keyboard. You will notice that your current directory has changed to C:\Windows”.

Command Prompt, cmd, Windows, basic, commands, files, folders

How to access a certain drive

To access another drive, type that drive’s letter, followed by :”. For instance, if you wanted to change the drive from “C:” to “D:”, you should type “d:” and then press Enter on your keyboard.

Command Prompt, cmd, Windows, basic, commands, files, folders

To change the drive and the directory at the same time, use the cd command, followed by the “/d” switch. The “/d” parameter is used to change the current drive to a specific folder from another disk volume. For instance, if you are now on the ”D:” drive and you want to go back to the Windows folder from the“C:” drive, you should type “cd /d C:\Windows” and press Enter on your keyboard, like in the following screenshot.

Command Prompt, cmd, Windows, basic, commands, files, folders

NOTE: By typing the drive letter you automatically move to your most recent location in that drive. For instance, if you are on “D:” drive and type “cd c:\windows” nothing seems to happen. But if you type c:”, then the working folder will change to “c:\windows” (assuming that it was the last folder you worked with on your “C:” drive).

How to view the contents of a folder

You can view the contents of a folder by using a simple command called DIR. To test it, we've created a folder named Digital_Citizen on the D: drive, with several files and subfolders.

Command Prompt, cmd, Windows, basic, commands, files, folders

The last time, our working folder was “C:\Windows”. We will navigate to the folder mentioned above by using the command “cd /d D:\Digital_Citizen”. To view the contents of the folder we will type DIR and press Enter on the keyboard. A list of the files and folders contained by it is displayed, together with some details about them (the size and the date and time when they were last modified).

Command Prompt, cmd, Windows, basic, commands, files, folders

How to create a new folder from the Command Prompt

You can make a new directory using the MKDIR (Make Directory) or the MD command. The syntax of these commands is MKDIR Folder” or “MD Folder”.

Let's say we need to create a new folder called Digital_Citizen_Life that will be placed in the “D:\Digital_Citizen” folder. We will type “mkdir Digital_Citizen_Life” and then we will press Enter, as shown below.

Command Prompt, cmd, Windows, basic, commands, files, folders

To test if it worked, we will use again the dir command. The newly created folder appears in the list.

Command Prompt, cmd, Windows, basic, commands, files, folders

NOTE: Don't forget that all these commands depend on the current location in the Command Prompt. For instance, if you are on the “C:” drive and type “MKDIR test”, a new folder will be created in the root of the “C:” drive.

Another way to create a folder, that doesn't involve being in the desired folder, is to type the complete path of the new folder. For example, if you are working on the “D:” drive and you want to create a new folder in “C:”, called other_stuff, type “mkdir c:\other_stuff” and then press Enter.

Command Prompt, cmd, Windows, basic, commands, files, folders

When you need to create a folder with subfolders at the same time you can use the ”MKDIR Folder\Subfolder” command . For instance, if we type “mkdir Digital_Citizen_Tests\Beta\Test1” three folders will be created: Digital_Citizen_Tests, Beta and Test1, in a tree-like structure.

Command Prompt, cmd, Windows, basic, commands, files, folders

How to rename files and folders

To rename files and folders you need to use the REN (Rename) command.

To rename folders, type “ren Folder NewFolderName”. For example, if we wanted to rename the  Digital_Citizen_Tests folder to Digital_Citizen_Final_Tests, we should run “ren Digital_Citizen_Tests Digital_Citizen_Final_Tests” and then press Enter.

Command Prompt, cmd, Windows, basic, commands, files, folders

To rename a file, use the same command, like this: “ren filename.extension newname.extension”. For instance, to rename the Digital_Citizen_Picture.jpg file to Picture1.jpg we have to run the command “ren Digital_Citizen_Picture.jpg Picture1.jpg” command.

Command Prompt, cmd, Windows, basic, commands, files, folders

Go to the second page of this tutorial and learn how to copy files and folders, how to delete files and folders, how to start and application and how to get help when using the Command Prompt.

Pages

About the Author: Codrut Neagu
Codrut is a Senior Editor on Digital Citizen. He's passionate about technology and he is fluent in working with several operating systems, including Windows and Linux. He likes to test security products and he feels like at home when digging through the registry, optimizing things or having fun on Telnet.