A command prompt (often abbreviated as cmd) is a command-line interpreter in which you can give commands to perform the functions on your PC. These functions include all the regular stuff like creating a new folder/file, deleting a folder/file, renaming, or navigating through the folders.
For example, If you want to create a new folder inside one of your drives, then you would follow these steps.
- Go to my computer/This PC.
- Go inside the drive by double-clicking its icon.
- Inside the drive, you can create right-click and select Folder under New Option. It is shown in the picture given below.
Once the folder is created you can rename it as you like.
Now what you can do, you can also create the folder directly through the command prompt by executing a specific command.
When Windows operating system was not in existence, the most common operating system was DOS (Disk Operating System). Windows is a GUI (Graphical User Interface) based operating system. You can navigate through different folders or drives by clicking on their icons in windows. Pretty easy! But this was not the scene with DOS. In DOS, the moment you boot up your PC, the first and the last thing you see was a black screen. There were no icons, nothing to be clicked. All you need to do is to execute commands to perform anything you want. That also means that a user should have extensive knowledge of the commands. But as time passed, newer operating systems replaced DOS. These operating systems are suitable for all users without them knowing any sort of commands. Since these operating systems are GUI-based, even a normal user can use the PC.
Even though the newer operating systems are not DOS-based, they have a command-line interpreter called the command prompt.
How to open command prompt?
You have two options.
Method 1 – click on the window key on your keyboard or click on the start menu icon. Then type command prompt. The option of command prompt would appear in the start menu. Click on it and the command prompt will be opened.
method 2 – Hit the window key and R key simultaneously. A dialog box named ‘Run’ would appear. Look at the picture given below.
Inside this box type cmd and press enter. The command prompt will be opened.
Now, every time you open the command prompt you would see the path something like this
This means that currently, we are inside a folder named ‘VASU’ which is inside another folder named ‘Users’ and the ‘Users’ folder is inside the C drive of our computer.
This is to be noted that every time you open the command prompt, the access is inside the folder of the current PC user.
Why should you use the command prompt?
If you are using Windows, you might be thinking “Why I need to use the command prompt if I have the GUI”? But, let me tell you that the command prompt is not just a replacement for GUI. It is so powerful that you can even do stuff you cannot do using the simple GUI.
There are several reasons why you need command prompt:
- The very first reason is speed. Command prompt works faster than the GUI.
- Apart from all the regular stuff like copying renaming files etc, the command prompt provides you commands to perform several other tasks. For example, the ‘netstat’ command can tell you about all the active network connections which your computer is trying to communicate with.
Some basic commands
cd – cd stands for Change Directory. This command is used to switch to some other directory (folder) from the current working directory.
C:\Users\VASU>cd documents C:\Users\VASU\Documents
cd.. – This command is also used to change the directory but in the backward direction. So for example right now if I am inside a folder named ‘mystuff’ which is inside D drive, then upon execution this command will take me out from this folder back to the D drive.
D:\sample> D:\sample>cd.. D:\>
change current drive – At any moment to change the drive, we need to put the drive name and a colon after the drive name.
Now the current working drive is D drive.
dir command – This command is used to list all the subdirectories inside a directory up to one level.
mkdir command – mkdir stands for ‘make directory. This command is used to create a new folder.
The above command will create a new folder named ‘test’ in D drive.
Here I have only given some of the basic commands. There are many more commands which I will cover in a separate article.
The applications of command prompt –
- Although we have a nice GUI in windows or other operating systems which allows us to navigate to do different places on our PC with ease, there are many things that you can only do using the command prompt.
- The knowledge of command prompt is highly recommended if you are a programmer. There are many software applications that require the knowledge of command prompt in production.
For example –
- An angular JS application.
- A Django-based application.